package com.handinfo.android.ui.window;

import java.io.DataInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Vector;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.widget.Toast;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.resource.Resource;
import com.handinfo.android.game.GameActor;
import com.handinfo.android.game.GameMessage;
import com.handinfo.android.game.Login;
import com.handinfo.android.game.Role;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.SimpleRole;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWAnimationBox;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWLabel;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWMessageBox;
import com.handinfo.android.uicontrols.controls.DWPopMenu;
import com.handinfo.android.uicontrols.controls.DWTabControl;
import com.handinfo.android.uicontrols.controls.DWTabPage;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

public class UISocial implements IUIWindows
{

	private boolean flag = false;
	public static DWFrame m_si_fram = null;
	private DWTitle m_si_title = null;
	private DWImageBox m_imageBox_title = null;
	private Bitmap m_bm_title = null;
	private DWPopMenu m_haoyou_popMenu = null;
	private DWPopMenu m_choudi_popMenu = null;
	private DWPopMenu m_blacklist_popMenu = null;
	private Bitmap m_bm_pop = null;
	private Bitmap m_bm_anxia = null;
	private String[] menus_haoyou = { "查看", "传音入密", "交易", "飞鸽传书", "邀请组队", "删除好友" };
	private String[] menus_haoyou01 = { "查看", "传音入密", "交易", "飞鸽传书", "邀请组队", "删除好友", "收徒" };
	private String[] menus_haoyou02 = { "查看", "传音入密", "交易", "飞鸽传书", "邀请组队", "删除好友", "拜师" };
	private String[] menus_choudi = { "查看", "查询位置", "锁定仇敌", "删除仇敌", "发布通缉令" };
	private String[] menus_choudi02 = { "查看", "查询位置", "解锁仇敌", "删除仇敌", "发布通缉令" };
	private String[] menus_heimingdan = { "查看", "解除" };
	private String[] m_si_caidan = { "好友", "仇敌", "黑名单", "我的队伍", "附近队伍", "师徒" };
	private DWTextbox[] m_text_friend = new DWTextbox[4];
	private DWTextbox[] m_text_enemy = new DWTextbox[4];
	private DWTextbox[] m_text_black = new DWTextbox[4];
	private DWTextbox[] m_text_myTeam = new DWTextbox[3];
	private DWTextbox[] m_text_nearTeam = new DWTextbox[3];

	private String m_label01 = "  姓名        " + "  " + "    等级  " + "  " + "    职业" + "  " + "   摇钱树 ";
	private String m_label02 = "  姓名        " + "  " + "    仇恨值 " + "  " + "    等级  " + "  " + "   职业";
	private String m_label03 = "  姓名        " + "  " + "    等级  " + "  " + "     职业" + "  " + "    阵营  ";
	private String m_label04 = "  姓名        " + "  " + "    等级  " + "  " + "     职业";
	private String m_label05 = "  队长        " + "  " + "    人数  " + "  " + "     操作";
	private DWListSubItem[] m_haoyou_si = new DWListSubItem[num];
	private DWListSubItem[] m_choudi_si = new DWListSubItem[num];
	private DWListSubItem[] m_heimingdan_si = new DWListSubItem[num];
	private DWTextbox[] m_haoyou_tb = new DWTextbox[5];
	private DWTextbox[] m_choudi_tb = new DWTextbox[5];
	private DWTextbox[] m_heimingdan_tb = new DWTextbox[5];
	private DWButton m_haoyou_add = null;//添加好友按钮
	private DWButton m_haoyou_tuijian = null;//添加好友按钮
	private DWButton m_heimingdan_add = null;//添加黑名单按钮
	private Bitmap m_si_addxia = null;
	private Bitmap[] m_si_bm = new Bitmap[5];
	public DWImageBox[] m_si_ib = new DWImageBox[1];
	private DWBackground m_si_background = null;
	private DWBackground m_si_backgroundRight = null;
	public DWTabControl m_si_tc = null;
	public DWTabPage[] m_si_tabPage = new DWTabPage[m_si_caidan.length];
	private DWListbox[] m_si_listBox = new DWListbox[m_si_caidan.length];
	private DWLabel[] m_si_label = new DWLabel[m_si_caidan.length];

	//右侧
	private DWListbox m_nature_listBox = null;
	public boolean m_isLook = false;
	private static String[] m_nature_str = {
			"名称：",
			"等级：",
			"VIP等级：",
			"职业：",
			"性别：",
			"门派：",
			"家族：",
			"配偶：",
			"" };
	private DWListSubItem[] m_nature_item = new DWListSubItem[m_nature_str.length];
	private DWTextbox[] m_nature_textBox = new DWTextbox[m_nature_str.length];

	//分页按钮
	private DWImageBox[] m_ib_left = new DWImageBox[3];
	private DWImageBox[] m_ib_right = new DWImageBox[3];
	private DWTextbox[] m_tb_page = new DWTextbox[3];
	private String[] m_page_str = new String[3];
	private Bitmap m_bm_left = null;
	private Bitmap m_bm_right = null;

	//好友数据
	private DWTextbox[][] m_haoyou_textBox = new DWTextbox[num][4];
	private DWImageBox[] m_haoyou_water = new DWImageBox[num];
	private Bitmap m_mingshuidi = null;
	private Bitmap m_anshuidi = null;
	private DWTextbox[][] m_choudi_textBox = new DWTextbox[num][4];
	private DWTextbox[][] m_backlist_textBox = new DWTextbox[num][4];
	private String[] haoyou = new String[5];
	private String[] choudi = new String[5];
	private String[] heimingdan = new String[5];

	public byte m_si_close = 0; //窗口关闭
	private byte m_si_beijing = 1;//菜单选项的背景

	private byte m_si_weixuanzhong = 2;//tab未选中
	private byte m_si_xuanzhong = 3;//tab选中
	private byte m_si_add = 4;//添加好友

	private int delete_friend_index = 0;
	private int delete_choudi_index = 0;
	private int delete_heimingdan_index = 0;

	public static int m_haoyou_name = 0;//标记
	private static int m_ok = 0;//为了防止不开界面添加出null

	public static final int num = 6;//每页显示行数
	Vector<SimpleRole> m_social_friend_list = new Vector<SimpleRole>(); //好友集合
	private int m_friend_currentPage = 0; // 好友当前页
	private int m_friend_totalPage = 1; // 好友总页数

	Vector<SimpleRole> m_social_black_list = new Vector<SimpleRole>(); //黑名单集合
	private int m_black_currentPage = 0; // 黑名单当前页
	private int m_black_totalPage = 1; // 黑名单总页数

	Vector<SimpleRole> m_social_enemy_list = new Vector<SimpleRole>(); //仇敌集合
	private int m_enemy_currentPage = 0; // 仇敌当前页
	private int m_enemy_totalPage = 1; // 仇敌总页数

	private int jishuqi = 0;
	public static final byte SOCIAL_TYPE_FRIEND = 0;// 好友
	public static final byte SOCIAL_TYPE_BLACKLIST = 1;// 黑名单
	public static final byte SOCIAL_TYPE_ENEMY = 2;// 仇敌

	private void socialCaidan()
	{
		m_si_fram = new DWFrame(DWFrame.FRAME_TYPE_FULL);//300 400
		m_si_fram.setClickClose(false);
		m_si_title = new DWTitle("", m_si_fram);

		//关闭X
		m_si_ib[m_si_close] = new DWImageBox(m_si_bm[m_si_close]);
//		m_si_ib[m_si_close].setShowWideHigh(28, 28);
		m_si_ib[m_si_close].setTouchZoomIn(50, 30);
		m_si_ib[m_si_close].setNearAnchor(m_si_title, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 0, 0);

		m_imageBox_title = new DWImageBox(m_bm_title);
		m_imageBox_title.setNearAnchor(m_si_title, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);

		//背景
		m_si_background = new DWBackground(370, 360);
		m_si_background.setFill(false);
		if (DWGameManager.AdpaterType == 2) {
			m_si_background
					.setShowWideHigh(DWGameManager.Screen_Width * 37 / 80, DWGameManager.Screen_Height * 36 / 48);
		}
		else {
			m_si_background.setNearAnchor(m_si_tc, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 0, 8);
		}

		//tab容器
		m_si_tc = new DWTabControl(m_si_bm[m_si_weixuanzhong], m_si_bm[m_si_xuanzhong],
				m_si_background.getShowWidth() * 2 + 10, m_si_background.getShowHeight()
						+ m_si_bm[m_si_weixuanzhong].getHeight());
		m_si_tc.setNearAnchor(m_si_title, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 5, 0);

		m_si_background.setNearAnchor(m_si_tc, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, m_si_bm[m_si_weixuanzhong]
				.getHeight());

		m_si_backgroundRight = new DWBackground(370, 360);
		if (DWGameManager.AdpaterType == 2) {
			m_si_backgroundRight.setShowWideHigh(DWGameManager.Screen_Width * 37 / 80,
					DWGameManager.Screen_Height * 36 / 48);
		}
		m_si_backgroundRight.setFill(false);
		m_si_backgroundRight.setNearAnchor(m_si_background, Tools.LEFT_TOP, Tools.RIGHT_TOP, 10, 0);

		if (DWGameManager.AdpaterType == 2) {
			m_nature_listBox = new DWListbox(300, 350);
		}
		else {
			m_nature_listBox = new DWListbox(200, 250);
		}
		m_nature_listBox.setNearAnchor(m_si_backgroundRight, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, -30);

		if (m_social_friend_list == null) {
			DWGameManager.getInstance().showToast("您还没有添加好友！", Toast.LENGTH_SHORT);
			return;
		}
		else {
			for (int i = 0; i < m_social_friend_list.size(); i++) {
				SimpleRole sr = m_social_friend_list.get(i);
				if (sr.m_isWatering == 1) {//不能

					if (sr.m_online == true) {

						if (DWGameManager.AdpaterType == 2) {
							m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
							m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 9 / 80);
							m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation,
									DWGameManager.Screen_Width * 8 / 80);
						}
						else {
							m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, 130);
							m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, 90);
							m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation, 80);
						}
						if (sr.m_vocation == 1) {
							m_haoyou_textBox[i][2].setText("剑客");
						}
						else if (sr.m_vocation == 2) {
							m_haoyou_textBox[i][2].setText("武者");
						}
						else if (sr.m_vocation == 3) {
							m_haoyou_textBox[i][2].setText("道士");
						}
					}
					else {

						if (DWGameManager.AdpaterType == 2) {
							m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
									DWGameManager.Screen_Width * 13 / 80);
							m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>",
									DWGameManager.Screen_Width * 9 / 80);
							m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>",
									DWGameManager.Screen_Width * 8 / 80);
						}
						else {
							m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
							m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>", 90);
							m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>", 80);
						}
					}

					m_haoyou_water[i] = new DWImageBox(m_anshuidi);
					m_haoyou_water[i].setShow(false);
				}
				else {
					if (sr.m_online == true) {

						if (DWGameManager.AdpaterType == 2) {
							m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
							m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 9 / 80);
							m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation,
									DWGameManager.Screen_Width * 8 / 80);
						}
						else {
							m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, 130);
							m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, 90);
							m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation, 80);
						}
						if (sr.m_vocation == 1) {
							m_haoyou_textBox[i][2].setText("剑客");
						}
						else if (sr.m_vocation == 2) {
							m_haoyou_textBox[i][2].setText("武者");
						}
						else if (sr.m_vocation == 3) {
							m_haoyou_textBox[i][2].setText("道士");
						}
					}
					else {

						if (DWGameManager.AdpaterType == 2) {
							m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
									DWGameManager.Screen_Width * 13 / 80);
							m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>",
									DWGameManager.Screen_Width * 9 / 80);
							m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>",
									DWGameManager.Screen_Width * 8 / 80);
						}
						else {
							m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
							m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>", 90);
							m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>", 80);
						}
					}
					m_haoyou_water[i] = new DWImageBox(m_mingshuidi);
				}

			}
		}

		//tab分页
		for (int i = 0; i < m_si_caidan.length; i++) {
			m_si_tabPage[i] = new DWTabPage();
			m_si_tabPage[i].setName(m_si_caidan[i]);
			if (i < m_si_caidan.length - 1) {
				m_si_tc.addTabPage(m_si_tabPage[i]);
			}

			//好友界面
			if (i == 0) {
				////////////////////////////婚姻///////////////////////////////
				UIWindows.getInstance().m_marriage.pageWindow();
				////////////////////////////////////////////////////////////

				if (DWGameManager.AdpaterType == 2) {
					m_text_friend[0] = new DWTextbox("   姓名", DWGameManager.Screen_Width * 13 / 80);
					m_text_friend[1] = new DWTextbox("等级", DWGameManager.Screen_Width * 9 / 80);
					m_text_friend[2] = new DWTextbox("职业", DWGameManager.Screen_Width * 8 / 80);
					m_text_friend[3] = new DWTextbox("摇钱树", DWGameManager.Screen_Width * 7 / 80);
				}
				else {
					m_text_friend[0] = new DWTextbox("   姓名", 130);
					m_text_friend[1] = new DWTextbox("等级", 90);
					m_text_friend[2] = new DWTextbox("职业", 80);
					m_text_friend[3] = new DWTextbox("摇钱树", 70);
				}
				m_text_friend[0].setNearAnchor(m_si_tabPage[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_friend[1].setNearAnchor(m_text_friend[0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_friend[2].setNearAnchor(m_text_friend[1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_friend[3].setNearAnchor(m_text_friend[2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

				if (DWGameManager.AdpaterType == 2) {
					m_si_listBox[i] = new DWListbox(DWGameManager.Screen_Width * 38 / 80, 400);
				}
				else {
					m_si_listBox[i] = new DWListbox(380, 250);
				}
				m_si_listBox[i].setShowBackgroundRect(true);
				m_si_listBox[i].setLineSpacing(10);
				m_si_listBox[i].addListener(friend_jianting);
				m_si_listBox[i].setNearAnchor(m_text_friend[0], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

				for (int j = 0; j < m_social_friend_list.size(); j++) {
					m_haoyou_si[j] = new DWListSubItem();
//					m_haoyou_tb[j] = new DWTextbox(haoyou[i]);
//					m_haoyou_tb[j].setNearAnchor(m_haoyou_si[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_haoyou_textBox[j][0].setNearAnchor(m_haoyou_si[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_haoyou_textBox[j][1].setNearAnchor(m_haoyou_textBox[j][0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
					m_haoyou_textBox[j][2].setNearAnchor(m_haoyou_textBox[j][1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
					m_haoyou_water[j].setNearAnchor(m_haoyou_textBox[j][2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

					m_haoyou_si[j].addControls(m_haoyou_textBox[j][0]);
					m_haoyou_si[j].addControls(m_haoyou_textBox[j][1]);
					m_haoyou_si[j].addControls(m_haoyou_textBox[j][2]);
					m_haoyou_si[j].addControls(m_haoyou_water[j]);
					m_si_listBox[i].addSubItem(m_haoyou_si[j]);
				}

				m_haoyou_add = new DWButton("手动添加", m_si_bm[m_si_add]);
				m_haoyou_add.setDownImage(m_si_addxia);
				if (DWGameManager.AdpaterType == 2) {
					m_haoyou_add.setNearAnchor(m_si_listBox[i], Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 0);
				}
				else {
					m_haoyou_add.setNearAnchor(m_si_listBox[i], Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 200, 50);
				}

				m_haoyou_tuijian = new DWButton("推荐好友", m_si_bm[m_si_add]);
				m_haoyou_tuijian.setDownImage(m_si_addxia);
				m_haoyou_tuijian.setNearAnchor(m_haoyou_add, Tools.LEFT_TOP, Tools.RIGHT_TOP, 100, 0);
				m_haoyou_tuijian.addListener(new DWListener() {

					public void OnDoubleClick()
					{

					}

					public void OnClick()
					{
						UIWindows.getInstance().m_tuijian.open(UITuiJian.TUIJIAN_HAOYOU);
					}
				});

				//分页
				m_ib_left[i] = new DWImageBox(m_bm_left);
				m_ib_left[i].addListener(friend_left);
				if (DWGameManager.AdpaterType == 2) {
					m_ib_left[i].setNearAnchor(m_si_listBox[i], Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 0);
				}
				else {
					m_ib_left[i].setNearAnchor(m_si_listBox[i], Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 10, 40);
				}

				m_tb_page[i] = new DWTextbox("", 50);
				m_tb_page[i].setNearAnchor(m_ib_left[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 20, 0);

				m_ib_right[i] = new DWImageBox(m_bm_right);
				m_ib_right[i].addListener(friend_right);
				m_ib_right[i].setNearAnchor(m_ib_left[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 70, 0);

				m_page_str[i] = "" + (m_friend_currentPage + 1) + "/" + m_friend_totalPage;
				m_tb_page[i].setText(m_page_str[i]);

				for (int j = 0; j < 4; j++) {
					m_si_tabPage[i].addControls(m_text_friend[j]);
				}

				m_si_tabPage[i].addControls(m_si_listBox[i]);
				m_si_tabPage[i].addControls(m_ib_left[i]);
				m_si_tabPage[i].addControls(m_tb_page[i]);
				m_si_tabPage[i].addControls(m_ib_right[i]);
				m_si_tabPage[i].addControls(m_haoyou_add);
				m_si_tabPage[i].addControls(m_haoyou_tuijian);
			}
			//仇敌
			else if (i == 1) {

				if (DWGameManager.AdpaterType == 2) {
					m_text_enemy[0] = new DWTextbox("   姓名", DWGameManager.Screen_Width * 13 / 80);
					m_text_enemy[1] = new DWTextbox("仇恨值", DWGameManager.Screen_Width * 9 / 80);
					m_text_enemy[2] = new DWTextbox("等级", DWGameManager.Screen_Width * 8 / 80);
					m_text_enemy[3] = new DWTextbox("锁定", DWGameManager.Screen_Width * 7 / 80);
				}
				else {
					m_text_enemy[0] = new DWTextbox("   姓名", 130);
					m_text_enemy[1] = new DWTextbox("仇恨值", 90);
					m_text_enemy[2] = new DWTextbox("等级", 80);
					m_text_enemy[3] = new DWTextbox("锁定", 70);
				}
				m_text_enemy[0].setNearAnchor(m_si_tabPage[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_enemy[1].setNearAnchor(m_text_enemy[0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_enemy[2].setNearAnchor(m_text_enemy[1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_enemy[3].setNearAnchor(m_text_enemy[2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				if (DWGameManager.AdpaterType == 2) {
					m_si_listBox[i] = new DWListbox(DWGameManager.Screen_Width * 38 / 80, 400);
				}
				else {
					m_si_listBox[i] = new DWListbox(380, 250);
				}
				m_si_listBox[i].setShowBackgroundRect(true);
				m_si_listBox[i].setLineSpacing(10);
				m_si_listBox[i].addListener(choudi_jianting);
				m_si_listBox[i].setNearAnchor(m_text_enemy[0], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

				for (int j = 0; j < m_social_enemy_list.size(); j++) {
					m_choudi_si[j] = new DWListSubItem();
					if (DWGameManager.AdpaterType == 2) {
						m_choudi_textBox[j][0] = new DWTextbox("", DWGameManager.Screen_Width * 13 / 80);
						m_choudi_textBox[j][1] = new DWTextbox("", DWGameManager.Screen_Width * 9 / 80);
						m_choudi_textBox[j][2] = new DWTextbox("", DWGameManager.Screen_Width * 8 / 80);
						m_choudi_textBox[j][3] = new DWTextbox("", DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_choudi_textBox[j][0] = new DWTextbox("", 130);
						m_choudi_textBox[j][1] = new DWTextbox("", 90);
						m_choudi_textBox[j][2] = new DWTextbox("", 80);
						m_choudi_textBox[j][3] = new DWTextbox("", 80);

					}

					m_choudi_textBox[j][0].setNearAnchor(m_choudi_si[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_choudi_textBox[j][1].setNearAnchor(m_choudi_textBox[j][0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
					m_choudi_textBox[j][2].setNearAnchor(m_choudi_textBox[j][1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
					m_choudi_textBox[j][3].setNearAnchor(m_choudi_textBox[j][2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

					m_choudi_si[j].addControls(m_choudi_textBox[j][0]);
					m_choudi_si[j].addControls(m_choudi_textBox[j][1]);
					m_choudi_si[j].addControls(m_choudi_textBox[j][2]);
					m_choudi_si[j].addControls(m_choudi_textBox[j][3]);
					m_si_listBox[i].addSubItem(m_choudi_si[j]);
				}

				//分页
				m_ib_left[i] = new DWImageBox(m_bm_left);
				m_ib_left[i].addListener(enemy_left);
				if (DWGameManager.AdpaterType == 2) {
					m_ib_left[i].setNearAnchor(m_si_listBox[i], Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 0);
				}
				else {
					m_ib_left[i].setNearAnchor(m_si_listBox[i], Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 10, 40);
				}
				m_tb_page[i] = new DWTextbox("", DWGameManager.Screen_Width * 5 / 80);
				m_tb_page[i].setNearAnchor(m_ib_left[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 20, 0);

				m_ib_right[i] = new DWImageBox(m_bm_right);
				m_ib_right[i].addListener(enemy_right);
				m_ib_right[i].setNearAnchor(m_ib_left[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 70, 0);

				m_page_str[i] = "" + (m_enemy_currentPage + 1) + "/" + m_enemy_totalPage;
				m_tb_page[i].setText(m_page_str[i]);

				for (int j = 0; j < 4; j++) {
					m_si_tabPage[i].addControls(m_text_enemy[j]);
				}
				m_si_tabPage[i].addControls(m_ib_left[i]);
				m_si_tabPage[i].addControls(m_tb_page[i]);
				m_si_tabPage[i].addControls(m_ib_right[i]);
				m_si_tabPage[i].addControls(m_si_label[i]);
				m_si_tabPage[i].addControls(m_si_listBox[i]);

			}
			//黑名单
			else if (i == 2) {
				if (DWGameManager.AdpaterType == 2) {
					m_text_black[0] = new DWTextbox("   姓名", DWGameManager.Screen_Width * 13 / 80);
					m_text_black[1] = new DWTextbox("等级", DWGameManager.Screen_Width * 9 / 80);
					m_text_black[2] = new DWTextbox("职业", DWGameManager.Screen_Width * 8 / 80);
					m_text_black[3] = new DWTextbox("阵营", DWGameManager.Screen_Width * 7 / 80);
				}
				else {
					m_text_black[0] = new DWTextbox("   姓名", 130);
					m_text_black[1] = new DWTextbox("等级", 90);
					m_text_black[2] = new DWTextbox("职业", 80);
					m_text_black[3] = new DWTextbox("阵营", 70);
				}
				m_text_black[0].setNearAnchor(m_si_tabPage[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_black[1].setNearAnchor(m_text_black[0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_black[2].setNearAnchor(m_text_black[1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_black[3].setNearAnchor(m_text_black[2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				if (DWGameManager.AdpaterType == 2) {
					m_si_listBox[i] = new DWListbox(DWGameManager.Screen_Width * 38 / 80, 400);
				}
				else {
					m_si_listBox[i] = new DWListbox(380, 250);
				}
				m_si_listBox[i].setShowBackgroundRect(true);
				m_si_listBox[i].setLineSpacing(10);
				m_si_listBox[i].addListener(heimingdan_jianting);
				m_si_listBox[i].setNearAnchor(m_text_black[0], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

				for (int j = 0; j < m_social_black_list.size(); j++) {
					m_heimingdan_si[j] = new DWListSubItem();

					if (DWGameManager.AdpaterType == 2) {

						m_backlist_textBox[j][0] = new DWTextbox("", DWGameManager.Screen_Width * 13 / 80);
						m_backlist_textBox[j][1] = new DWTextbox("", DWGameManager.Screen_Width * 9 / 80);
						m_backlist_textBox[j][2] = new DWTextbox("", DWGameManager.Screen_Width * 8 / 80);
						m_backlist_textBox[j][3] = new DWTextbox("", DWGameManager.Screen_Width * 8 / 80);
					}
					else {

						m_backlist_textBox[j][0] = new DWTextbox("", 130);
						m_backlist_textBox[j][1] = new DWTextbox("", 90);
						m_backlist_textBox[j][2] = new DWTextbox("", 80);
						m_backlist_textBox[j][3] = new DWTextbox("", 80);
					}

					m_backlist_textBox[j][0].setNearAnchor(m_heimingdan_si[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_backlist_textBox[j][1].setNearAnchor(m_backlist_textBox[j][0], Tools.LEFT_TOP, Tools.RIGHT_TOP,
							0, 0);
					m_backlist_textBox[j][2].setNearAnchor(m_backlist_textBox[j][1], Tools.LEFT_TOP, Tools.RIGHT_TOP,
							0, 0);
					m_backlist_textBox[j][3].setNearAnchor(m_backlist_textBox[j][2], Tools.LEFT_TOP, Tools.RIGHT_TOP,
							0, 0);

					m_heimingdan_si[j].addControls(m_backlist_textBox[j][0]);
					m_heimingdan_si[j].addControls(m_backlist_textBox[j][1]);
					m_heimingdan_si[j].addControls(m_backlist_textBox[j][2]);
					m_heimingdan_si[j].addControls(m_backlist_textBox[j][3]);
					m_si_listBox[i].addSubItem(m_heimingdan_si[j]);
				}
				m_heimingdan_add = new DWButton("添加黑名单", m_si_bm[m_si_add]);
				m_heimingdan_add.setDownImage(m_si_addxia);
				if (DWGameManager.AdpaterType == 2) {
					m_heimingdan_add.setNearAnchor(m_si_listBox[i], Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 0);
				}
				else {
					m_heimingdan_add.setNearAnchor(m_si_listBox[i], Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 200, 50);
				}
				//分页
				m_ib_left[i] = new DWImageBox(m_bm_left);
				m_ib_left[i].addListener(black_left);
				if (DWGameManager.AdpaterType == 2) {
					m_ib_left[i].setNearAnchor(m_si_listBox[i], Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 50);
				}
				else {
					m_ib_left[i].setNearAnchor(m_si_listBox[i], Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 10, 80);
				}

				m_tb_page[i] = new DWTextbox("", DWGameManager.Screen_Width * 5 / 80);
//				m_tb_page[i].setFont(DWFont.getFont(20));
				m_tb_page[i].setNearAnchor(m_ib_left[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 20, 0);

				m_ib_right[i] = new DWImageBox(m_bm_right);
				m_ib_right[i].addListener(black_right);
				m_ib_right[i].setNearAnchor(m_ib_left[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 70, 0);

				m_page_str[i] = "" + (m_black_currentPage + 1) + "/" + m_black_totalPage;
				m_tb_page[i].setText(m_page_str[i]);

				for (int j = 0; j < 4; j++) {
					m_si_tabPage[i].addControls(m_text_black[j]);
				}
				m_si_tabPage[i].addControls(m_ib_left[i]);
				m_si_tabPage[i].addControls(m_ib_right[i]);
				m_si_tabPage[i].addControls(m_tb_page[i]);

				m_si_tabPage[i].addControls(m_si_listBox[i]);
				m_si_tabPage[i].addControls(m_heimingdan_add);
			}
			else if (i == 3) {

				if (DWGameManager.AdpaterType == 2) {
					m_text_myTeam[0] = new DWTextbox("   姓名", DWGameManager.Screen_Width * 13 / 80);
					m_text_myTeam[1] = new DWTextbox("等级", DWGameManager.Screen_Width * 12 / 80);
					m_text_myTeam[2] = new DWTextbox("职业", DWGameManager.Screen_Width * 8 / 80);
				}
				else {
					m_text_myTeam[0] = new DWTextbox("   姓名", 130);
					m_text_myTeam[1] = new DWTextbox("等级", 120);
					m_text_myTeam[2] = new DWTextbox("职业", 80);
				}
				m_text_myTeam[0].setNearAnchor(m_si_tabPage[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_myTeam[1].setNearAnchor(m_text_myTeam[0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_myTeam[2].setNearAnchor(m_text_myTeam[1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				if (DWGameManager.AdpaterType == 2) {
					m_si_listBox[i] = new DWListbox(DWGameManager.Screen_Width * 38 / 80, 400);
				}
				else {
					m_si_listBox[i] = new DWListbox(380, 250);
				}
				m_si_listBox[i].setShowBackgroundRect(true);
				m_si_listBox[i].setLineSpacing(10);
				m_si_listBox[i].addListener(m_listBox_team);
				m_si_listBox[i].setNearAnchor(m_text_myTeam[0], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

				refreshMyTeam();

				for (int j = 0; j < 3; j++) {
					m_si_tabPage[i].addControls(m_text_myTeam[j]);
				}
				m_si_tabPage[i].addControls(m_si_listBox[i]);
//				m_si_tabPage[i].addControls(m_heimingdan_add);
			}
			else if (i == 4) {

				if (DWGameManager.AdpaterType == 2) {
					m_text_nearTeam[0] = new DWTextbox("   队长", DWGameManager.Screen_Width * 13 / 80);
					m_text_nearTeam[1] = new DWTextbox("人数", DWGameManager.Screen_Width * 12 / 80);
				}
				else {
					m_text_nearTeam[0] = new DWTextbox("   队长", 130);
					m_text_nearTeam[1] = new DWTextbox("人数", 120);
				}
//				m_text_nearTeam[2] = new DWTextbox("操作",80);
				m_text_nearTeam[0].setNearAnchor(m_si_tabPage[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_nearTeam[1].setNearAnchor(m_text_nearTeam[0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
//				m_text_nearTeam[2].setNearAnchor(m_text_nearTeam[1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				if (DWGameManager.AdpaterType == 2) {
					m_si_listBox[i] = new DWListbox(DWGameManager.Screen_Width * 38 / 80, 300);
				}
				else {
					m_si_listBox[i] = new DWListbox(380, 250);
				}
				m_si_listBox[i].setShowBackgroundRect(true);
				m_si_listBox[i].setLineSpacing(10);
				m_si_listBox[i].addListener(m_listBox_nearTeam);
				m_si_listBox[i].setNearAnchor(m_text_nearTeam[0], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

				DWButton m_button = new DWButton("刷新", m_bm_pop);
				m_button.setDownImage(m_bm_anxia);
				m_button.addListener(m_refresh_button);
				m_button.setNearAnchor(m_si_listBox[4], Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 0);

				refreshNearTeam();

				for (int j = 0; j < 2; j++) {
					m_si_tabPage[i].addControls(m_text_nearTeam[j]);
				}
//				m_si_tabPage[i].addControls(m_ib_left[i]);
//				m_si_tabPage[i].addControls(m_ib_right[i]);
//				m_si_tabPage[i].addControls(m_tb_page[i]);
				m_si_tabPage[i].addControls(m_button);
				m_si_tabPage[i].addControls(m_si_listBox[i]);
//				m_si_tabPage[i].addControls(m_heimingdan_add);
			}
			else if (i == 5) {
//				teacherAndPupil(0);
				m_si_tc.addTabPage(m_si_tabPage[5]);
			}

		}

		m_si_fram.addControl(m_si_background);
		m_si_fram.addControl(m_si_backgroundRight);
		m_si_fram.addControl(m_nature_listBox);
		m_si_fram.addControl(m_si_title);
		m_si_fram.addControl(m_si_ib[m_si_close]);
		m_si_fram.addControl(m_si_tc);
		m_si_fram.addControl(m_imageBox_title);
		DWControlsManager.getInstance().addControl(m_si_fram);
//		
		//tab容器进行监听
		m_si_tc.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (DWGameManager.getInstance().getSendMessage().isNetLocked(GameMessage.锁_队伍) == true) {
					return;
				}
				m_si_background.setShow(true);
				m_si_backgroundRight.setShow(true);
				int index = m_si_tc.getPageIndex();
				m_nature_listBox.removeAllSubItem();
				switch (index) {
					case 0:
						DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_FRIEND,
								m_friend_currentPage, num);
						break;
					case 2:
						DWGameManager.getInstance().getSendMessage().sendEnemyList((short) m_enemy_currentPage,
								(short) num);

						break;
					case 3:
						DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_BLACKLIST,
								m_black_currentPage, num);
						break;
					case 4:
						DWGameManager.getInstance().getSendMessage().sendTeamAllMsg();//查看全队信息
						break;
					case 5://查看附近队伍
						DWGameManager.getInstance().getSendMessage().sendTeamNear();
						break;
					case 6://师徒
						m_si_background.setShow(false);
						m_si_backgroundRight.setShow(false);
						refresh();
						DWGameManager.getInstance().getSendMessage().sendBaiShiOpen();
						break;
				}

			}

		});

		//关闭窗口
		m_si_ib[m_si_close].addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
//				DWControlsManager.getInstance().removeControl(m_si_fram);
				UIWindows.getInstance().m_social.close((byte) 0);

			}
		});
		//添加好友
		m_haoyou_add.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				UIWindows.getInstance().m_friend.open((byte) 0);
			}
		});
		//添加黑名单
		m_heimingdan_add.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				UIWindows.getInstance().m_blackList.open((byte) 0);
			}
		});

	}

	//list监听
	private DWListener friend_jianting = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_si_listBox[0].getTouchIndex();
			delete_friend_index = index;
			SimpleRole sr = m_social_friend_list.get(delete_friend_index);
			DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
			m_isLook = true;
			if (m_haoyou_name == 1) {//邮件
//				UIMail m_uiMail = new UIMail();
//				m_uiMail.setName(sr.m_name);
				UIWindows.getInstance().m_mail.m_send_recv_ib.setText(sr.m_name);
//				m_haoyou_name = 0;
			}
			else if (m_haoyou_name == 2) {//婚姻
				UIWindows.getInstance().m_marriage.input_inputName.setText(sr.m_name);
//				m_haoyou_name = 0;
			}
			else {
				if (sr.m_grade <= DWGameManager.getInstance().m_role.m_shitu_tudilv) {// 目标等级是徒弟
					if (DWGameManager.getInstance().m_role.m_lv >= DWGameManager.getInstance().m_role.m_shitu_laoshi) {// 自己是师父
						m_haoyou_popMenu = new DWPopMenu(menus_haoyou01, m_bm_pop);
					}
					else {
						m_haoyou_popMenu = new DWPopMenu(menus_haoyou, m_bm_pop);
					}
				}
				else if (sr.m_grade >= DWGameManager.getInstance().m_role.m_shitu_laoshi) {//目标是老师
					if (DWGameManager.getInstance().m_role.m_lv <= DWGameManager.getInstance().m_role.m_shitu_tudilv) {
						m_haoyou_popMenu = new DWPopMenu(menus_haoyou02, m_bm_pop);
					}
					else {
						m_haoyou_popMenu = new DWPopMenu(menus_haoyou, m_bm_pop);
					}

				}
				else {
					m_haoyou_popMenu = new DWPopMenu(menus_haoyou, m_bm_pop);
				}

				m_haoyou_popMenu.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
				m_haoyou_popMenu.setDownImage(m_bm_anxia);
				m_haoyou_popMenu.addListener(m_haoyou_pm);
				m_si_fram.addControl(m_haoyou_popMenu);
			}
		}
	};
	private DWListener choudi_jianting = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_si_listBox[1].getTouchIndex();
			delete_choudi_index = index;
			m_choudi_popMenu = new DWPopMenu(menus_choudi, m_bm_pop);
			m_choudi_popMenu.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
			m_choudi_popMenu.setDownImage(m_bm_anxia);
			SimpleRole sr = m_social_enemy_list.get(delete_choudi_index);
			DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
			m_isLook = true;
//			if(sr.m_is_Locked == true){		
//				m_choudi_popMenu.setMenus(menus_choudi02);
//			}else{
			m_choudi_popMenu.setMenus(menus_choudi);
//			}

			m_choudi_popMenu.addListener(m_choudi_pm);
			m_si_fram.addControl(m_choudi_popMenu);
		}
	};
	private DWListener heimingdan_jianting = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_si_listBox[2].getTouchIndex();
			delete_heimingdan_index = index;
			SimpleRole sr = m_social_black_list.get(delete_heimingdan_index);
			DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
			m_isLook = true;
			m_blacklist_popMenu = new DWPopMenu(menus_heimingdan, m_bm_pop);
			m_blacklist_popMenu.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
			m_blacklist_popMenu.setDownImage(m_bm_anxia);
			m_blacklist_popMenu.addListener(m_blacklist_pm);
			m_si_fram.addControl(m_blacklist_popMenu);
		}
	};

	//菜单监听
	public boolean m_shejiao_siliao_flag = true;
	public long m_cyrm_id = 0;
	private DWListener m_haoyou_pm = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_haoyou_popMenu.getIndex();
			SimpleRole sr = m_social_friend_list.get(delete_friend_index);
			switch (index) {
				case 0://查看
					m_isLook = false;
					DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
					break;
				case 1://传音入密
					m_shejiao_siliao_flag = false;
					m_cyrm_id = sr.m_gameID;
					UIWindows.getInstance().m_checked.ChatPrivate(sr.m_gameID, sr.m_name);
					break;
				case 2://交易
					UIWindows.getInstance().m_exchang.setActor(sr.m_gameID, sr.m_name);
					UIWindows.getInstance().m_exchang.open((byte) 0);
					break;
				case 3://飞鸽传书
					UIWindows.getInstance().m_mail.open((byte) 0);
					UIWindows.getInstance().m_mail.m_tabcontrol.setSelectPage(1);
					UIWindows.getInstance().m_mail.m_send_recv_ib.setText(sr.m_name);
					break;
				case 4://邀请组队
					DWGameManager.getInstance().getSendMessage().sendTeamRequest(sr.m_gameID);
					break;
				case 5://删除好友
					DWGameManager.getInstance().getSendMessage().sendSocialDelete(SOCIAL_TYPE_FRIEND, sr.m_gameID);
					break;
				case 6://收徒
					DWGameManager.getInstance().getSendMessage().sendBaiShi(sr.m_gameID);
					break;

			}
			m_si_fram.removeControl(m_haoyou_popMenu);
		}
	};

	private DWListener m_choudi_pm = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_choudi_popMenu.getIndex();
			SimpleRole sr = m_social_enemy_list.get(delete_choudi_index);
			switch (index) {
				case 0://查看
					m_isLook = false;
					DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
					break;
				case 1://查询位置
					DWGameManager.getInstance().getSendMessage().sendEnemyPosition(sr.m_gameID);
					break;
				case 2://锁定（解锁）仇敌
					DWGameManager.getInstance().getSendMessage().sendEnemyLock(sr.m_gameID);
					break;
				case 3://删除仇敌
//					if(sr.m_is_Locked == true){
//						DWGameManager.getInstance().showToast("请先解锁仇敌", Toast.LENGTH_SHORT);
//						return;
//					}
					DWGameManager.getInstance().getSendMessage().sendEnemyDelete(sr.m_gameID);
					break;
				case 4://发布通缉令
//					DWGameManager.getInstance().showToast("稍后开放，敬请期待！", Toast.LENGTH_SHORT);
					UIWindows.getInstance().m_warrant.open((byte) 0);
					UIWindows.getInstance().m_warrant.setMessage(sr.m_gameID, sr.m_name);
//					DWGameManager.getInstance().getSendMessage().sendEnemyWanted(sr.m_gameID, sr.m_name, moneyAwardState, moneyAwardNum, msg);
					break;
			}
			m_si_fram.removeControl(m_choudi_popMenu);
		}
	};

	private DWListener m_blacklist_pm = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_blacklist_popMenu.getIndex();
			SimpleRole sr = m_social_black_list.get(delete_heimingdan_index);
			switch (index) {
				case 0://查看
					m_isLook = false;
					DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
					break;
				case 1://解除黑名单

					DWGameManager.getInstance().getSendMessage().sendSocialDelete(UISocial.SOCIAL_TYPE_BLACKLIST,
							sr.m_gameID);
					break;
			}
			m_si_fram.removeControl(m_blacklist_popMenu);
		}
	};

	//左翻页(好友)
	private DWListener friend_left = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_friend_currentPage == 0) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前是最小页");
			}
			else {
				DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_FRIEND,
						m_friend_currentPage - 1, num);
			}
		}
	};

	//右翻页
	private DWListener friend_right = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_friend_currentPage + 1 == m_friend_totalPage) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前是最大页");
			}
			else {
				Tools.debugPrintln("---------------." + m_friend_currentPage);
				DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_FRIEND,
						m_friend_currentPage + 1, num);

			}

		}
	};

	//左翻页(仇敌)
	private DWListener enemy_left = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_enemy_currentPage == 0) {

				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前是最小页");
			}
			else {
				DWGameManager.getInstance().getSendMessage()
						.sendEnemyList((short) (m_enemy_currentPage - 1), (short) num);
			}
		}
	};

	//右翻页
	private DWListener enemy_right = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_enemy_currentPage + 1 == m_enemy_totalPage) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前是最大页");
			}
			else {
				DWGameManager.getInstance().getSendMessage()
						.sendEnemyList((short) (m_enemy_currentPage + 1), (short) num);
			}

		}
	};

	//左翻页(黑名单)
	private DWListener black_left = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_black_currentPage == 0) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前是最小页");
			}
			else {
				DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_BLACKLIST,
						m_black_currentPage - 1, num);
			}
		}
	};

	//右翻页
	private DWListener black_right = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_black_currentPage + 1 == m_black_totalPage) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前是最大页");
			}
			else {
				DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_BLACKLIST,
						m_black_currentPage + 1, num);
			}

		}
	};

	//刷新右侧 "名称：","等级："VIP等级：","职业：","性别：","派：","家族：","配偶："}
	public void refreshRightList(String string)
	{
		String[] str = string.split(",");
		if (Integer.valueOf(str[3]) == 1) {
			str[3] = "剑客";
		}
		else if (Integer.valueOf(str[3]) == 2) {
			str[3] = "武者";
		}
		else if (Integer.valueOf(str[3]) == 3) {
			str[3] = "道士";
		}
		if (Integer.valueOf(str[4]) == 1) {
			str[4] = "男";
		}
		else if (Integer.valueOf(str[4]) == 2) {
			str[4] = "女";
		}
		if (Integer.valueOf(str[5]) == 1) {
			str[5] = "灵隐";
		}
		else {
			str[5] = "天机";
		}

		m_nature_listBox.removeAllSubItem();
		for (int i = 0; i < m_nature_str.length; i++) {
			m_nature_item[i] = new DWListSubItem();
			m_nature_textBox[i] = new DWTextbox(m_nature_str[i] + str[i]);
			m_nature_textBox[i].setNearAnchor(m_nature_item[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
			m_nature_item[i].addControls(m_nature_textBox[i]);
			m_nature_listBox.addSubItem(m_nature_item[i]);
		}

	}

	private void getNature()
	{

	}

	public void init()
	{
		m_si_bm[m_si_close] = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp");
		m_bm_title = UIWindows.createImage("/img/newui/shejiao_1.gnp");
		m_si_bm[m_si_weixuanzhong] = UIWindows.createImage("/img/newui/biaoqianye_1.gnp");
		m_si_bm[m_si_xuanzhong] = UIWindows.createImage("/img/newui/biaoqianye_2.gnp");
		m_si_bm[m_si_add] = UIWindows.createImage("/img/newui/anniu_6.gnp");
		m_si_addxia = UIWindows.createImage("/img/newui/anniu_6ax.gnp");
		m_bm_left = UIWindows.createImage("/img/newui/haoyoufyan_2.gnp");
		m_bm_right = UIWindows.createImage("/img/newui/haoyoufyan_1.gnp");
		m_bm_pop = UIWindows.createImage("/img/newui/anniu_6.gnp");
		m_bm_anxia = UIWindows.createImage("/img/newui/anniu_6ax.gnp");
		m_mingshuidi = UIWindows.createImage("/img/newui/yaoqianshugg_1.gnp");
		m_anshuidi = UIWindows.createImage("/img/newui/yaoqianshugg_2.gnp");

		m_bm_team = UIWindows.createImage("/img/newui/anniu_5.gnp");
	}

	public void open(byte index)
	{
		if (flag == false) {
			socialCaidan();
			flag = true;
		}
		else {
			if (m_si_fram != null) {
				DWControlsManager.getInstance().addControl(m_si_fram);
				UIWindows.getInstance().m_marriage.refreshPage();
			}
			else {
				return;
			}
		}

	}

	public void close(byte index)
	{
		m_haoyou_name = 0;
		flag = false;
		m_isLook = false;
		UIWindows.getInstance().m_marriage.close((byte) 0);
		DWControlsManager.getInstance().removeControl(m_si_fram);

	}

	public void dispose()
	{
	}

	/**
	 * 读取社交界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialList(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_社交);
		byte state = dis.readByte();
		Tools.debugPrintln("social list state = " + state);
		if (state == 1) {
			byte listType = dis.readByte();// 列表类型
			Tools.debugPrintln("type = " + listType);

			int currentPage = dis.readInt();//当前页
			if (currentPage == -1) {
				return;
			}
			Tools.debugPrintln("currentPage = " + currentPage);
			int sumPag = dis.readInt();
			Tools.debugPrintln("总页数：" + sumPag);
			int listCount = dis.readInt();
			Tools.debugPrintln("社交列表添加数量 : " + listCount);
			Vector<SimpleRole> m_social_list = new Vector<SimpleRole>();
			for (int i = 0; i < listCount; i++) {
				SimpleRole role = new SimpleRole();
				role.m_online = dis.readByte() == 0 ? true : false;// 是否在线
				// 0在线
				// 1不在线
				role.m_gameID = dis.readLong();
				role.m_name = dis.readUTF();
				Tools.debugPrintln("online = " + role.m_online);
				Tools.debugPrintln("id = " + role.m_gameID);
				Tools.debugPrintln("name = " + role.m_name);
				if (role.m_online) {
					role.m_grade = dis.readInt();
					role.m_vocation = dis.readByte();
					Tools.debugPrintln("grade = " + role.m_grade);
					Tools.debugPrintln("vocation = " + role.m_vocation);
					if (listType == SOCIAL_TYPE_BLACKLIST) {
						role.m_faction = dis.readByte();
						Tools.debugPrintln("m_faction = " + role.m_faction);
					}
				}
				if (listType == SOCIAL_TYPE_FRIEND) {
					role.m_isWatering = dis.readByte(); // 是否能浇水
				}
				m_social_list.addElement(role);
			}
			switch (listType) {
				case SOCIAL_TYPE_FRIEND:
					m_social_friend_list = m_social_list;
					m_friend_currentPage = currentPage;
					if (sumPag > 0) {
						m_friend_totalPage = sumPag;//总页数
						if (m_friend_totalPage == 0) {
							m_friend_totalPage = 1;
						}
						Tools.debugPrintln("m_friend_totalPage = " + m_friend_totalPage);
					}
					break;
				case SOCIAL_TYPE_BLACKLIST:
					m_social_black_list = m_social_list;
					m_black_currentPage = currentPage;
					if (sumPag > 0) {
						m_black_totalPage = sumPag;//总页数
						if (m_black_totalPage == 0) {
							m_black_totalPage = 1;
						}
						Tools.debugPrintln("m_black_totalPage = " + m_black_totalPage);
					}
					break;
			}

			if (jishuqi > 0) {
				if (listType == SOCIAL_TYPE_FRIEND) {
					//好友
					if (m_social_friend_list == null) {
						return;
					}
					m_si_listBox[0].removeAllSubItem();
					refreshFriend();

				}
				else if (listType == SOCIAL_TYPE_BLACKLIST) {
					Tools.debugPrintln("-----------------------geg---------ge-----------");
					if (m_social_black_list == null) {
						return;
					}
					if (flag == false) {
						return;
					}
					m_si_listBox[2].removeAllSubItem();
					refreshBlack();
				}

			}

			//黑名单
			if (m_social_black_list != null) {

			}
			else {

			}

		}
		else {
//			Tools.debugPrintln("读取社交界面异常 : " + msg);
		}
		jishuqi = 1;
		UIWindows.getInstance().m_social.open((byte) 0);
	}

	//刷新好友listbox
	private void refreshFriend()
	{
		for (int i = 0; i < m_social_friend_list.size(); i++) {
			SimpleRole sr = m_social_friend_list.get(i);

			if (sr.m_isWatering == 1) {//不能
				if (sr.m_online == true) {

					if (DWGameManager.AdpaterType == 2) {
						m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
						m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 9 / 80);
						m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation, DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, 130);
						m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, 90);
						m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation, 80);
					}
					if (sr.m_vocation == 1) {
						m_haoyou_textBox[i][2].setText("剑客");
					}
					else if (sr.m_vocation == 2) {
						m_haoyou_textBox[i][2].setText("武者");
					}
					else if (sr.m_vocation == 3) {
						m_haoyou_textBox[i][2].setText("道士");
					}
				}
				else {

					if (DWGameManager.AdpaterType == 2) {
						m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
								DWGameManager.Screen_Width * 13 / 80);
						m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>",
								DWGameManager.Screen_Width * 9 / 80);
						m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>",
								DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
						m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>", 90);
						m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>", 80);
					}
				}

				m_haoyou_water[i] = new DWImageBox(m_anshuidi);
				m_haoyou_water[i].setShow(false);
			}
			else {
				if (sr.m_online == true) {

					if (DWGameManager.AdpaterType == 2) {
						m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
						m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 9 / 80);
						m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation, DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_haoyou_textBox[i][0] = new DWTextbox(sr.m_name, 130);
						m_haoyou_textBox[i][1] = new DWTextbox("" + sr.m_grade, 90);
						m_haoyou_textBox[i][2] = new DWTextbox("" + sr.m_vocation, 80);
					}
					if (sr.m_vocation == 1) {
						m_haoyou_textBox[i][2].setText("剑客");
					}
					else if (sr.m_vocation == 2) {
						m_haoyou_textBox[i][2].setText("武者");
					}
					else if (sr.m_vocation == 3) {
						m_haoyou_textBox[i][2].setText("道士");
					}
				}
				else {

					if (DWGameManager.AdpaterType == 2) {
						m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
								DWGameManager.Screen_Width * 13 / 80);
						m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>",
								DWGameManager.Screen_Width * 9 / 80);
						m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>",
								DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_haoyou_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
						m_haoyou_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>", 90);
						m_haoyou_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>", 80);
					}
				}
				m_haoyou_water[i] = new DWImageBox(m_mingshuidi);
			}

			m_haoyou_si[i] = new DWListSubItem();
			m_haoyou_textBox[i][0].setNearAnchor(m_haoyou_si[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
			m_haoyou_textBox[i][1].setNearAnchor(m_haoyou_textBox[i][0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_haoyou_textBox[i][2].setNearAnchor(m_haoyou_textBox[i][1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_haoyou_water[i].setNearAnchor(m_haoyou_textBox[i][2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

			m_haoyou_si[i].addControls(m_haoyou_textBox[i][0]);
			m_haoyou_si[i].addControls(m_haoyou_textBox[i][1]);
			m_haoyou_si[i].addControls(m_haoyou_textBox[i][2]);
			m_haoyou_si[i].addControls(m_haoyou_water[i]);
			m_si_listBox[0].addSubItem(m_haoyou_si[i]);

		}
		m_page_str[0] = "" + (m_friend_currentPage + 1) + "/" + m_friend_totalPage;
		m_tb_page[0].setText(m_page_str[0]);
	}

	//刷新黑名单
	private void refreshBlack()
	{
		Tools.debugPrintln("黑名单数-------------------》" + m_social_black_list.size());
		for (int i = 0; i < m_social_black_list.size(); i++) {
			SimpleRole sr = m_social_black_list.get(i);
			if (sr.m_online == true) {
				m_heimingdan_si[i] = new DWListSubItem();

				if (DWGameManager.AdpaterType == 2) {
					m_backlist_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
					m_backlist_textBox[i][1] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 9 / 80);
					m_backlist_textBox[i][2] = new DWTextbox("" + sr.m_vocation, DWGameManager.Screen_Width * 8 / 80);
				}
				else {
					m_backlist_textBox[i][0] = new DWTextbox(sr.m_name, 130);
					m_backlist_textBox[i][1] = new DWTextbox("" + sr.m_grade, 90);
					m_backlist_textBox[i][2] = new DWTextbox("" + sr.m_vocation, 80);
				}
				if (sr.m_vocation == 1) {
					m_backlist_textBox[i][2].setText("剑客");
				}
				else if (sr.m_vocation == 2) {
					m_backlist_textBox[i][2].setText("武者");
				}
				else if (sr.m_vocation == 3) {
					m_backlist_textBox[i][2].setText("道士");
				}

				m_backlist_textBox[i][3] = new DWTextbox("" + sr.m_camp, 80);
				if (sr.m_camp == 0) {
					m_backlist_textBox[i][3].setText("灵隐");
				}
				else if (sr.m_camp == 1) {
					m_backlist_textBox[i][3].setText("天机");
				}
			}
			else {
				m_heimingdan_si[i] = new DWListSubItem();

				if (DWGameManager.AdpaterType == 2) {
					m_backlist_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
							DWGameManager.Screen_Width * 13 / 80);
					m_backlist_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>",
							DWGameManager.Screen_Width * 9 / 80);
					m_backlist_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>",
							DWGameManager.Screen_Width * 8 / 80);
					m_backlist_textBox[i][3] = new DWTextbox("<mark c=818080>--</mark>",
							DWGameManager.Screen_Width * 8 / 80);
				}
				else {
					m_backlist_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
					m_backlist_textBox[i][1] = new DWTextbox("<mark c=818080>--</mark>", 90);
					m_backlist_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>", 80);
					m_backlist_textBox[i][3] = new DWTextbox("<mark c=818080>--</mark>", 80);
				}
			}

			m_backlist_textBox[i][0].setNearAnchor(m_heimingdan_si[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
			m_backlist_textBox[i][1].setNearAnchor(m_backlist_textBox[i][0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_backlist_textBox[i][2].setNearAnchor(m_backlist_textBox[i][1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_backlist_textBox[i][3].setNearAnchor(m_backlist_textBox[i][2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

			m_heimingdan_si[i].addControls(m_backlist_textBox[i][0]);
			m_heimingdan_si[i].addControls(m_backlist_textBox[i][1]);
			m_heimingdan_si[i].addControls(m_backlist_textBox[i][2]);
			m_heimingdan_si[i].addControls(m_backlist_textBox[i][3]);
			m_si_listBox[2].addSubItem(m_heimingdan_si[i]);

		}
		m_page_str[2] = "" + (m_black_currentPage + 1) + "/" + m_black_totalPage;
		m_tb_page[2].setText(m_page_str[2]);
	}

	/**
	 * 读取添加玩家
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialAdd(DataInputStream dis) throws IOException
	{
		byte state = dis.readByte();
		Tools.debugPrintln("state = " + state);
		switch (state) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"您不能添加自己为好友 ");
				break;
			case 1:
				break;
			case 2:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"您的好友列表已满");
				break;
			case 3:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方已经在您的好友列表当中");
				break;
			case 4:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"您已经向对方发送了好友请求，请耐心等待对方的确认");
				break;
			case 5:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方不在线");
				break;
			case 6:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方好友列表已满");
				break;
			case 7:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方已将您拉入黑名单");
				break;
			case 8:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方当前的状态不能做出回应，请稍后再试");
				break;
			case 9:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"您的黑名单列表已满");
				break;
			case 10:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方已经在您的黑名单中");
				break;
			case 11:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"对方拒绝了您的好友请求");
				break;
			case 12:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
						"失败 对方和您不是一个阵营");
				break;

		}
		if (state == 1) {
			SimpleRole role = new SimpleRole();
			byte type = dis.readByte();
			role.m_gameID = dis.readLong();
			role.m_name = dis.readUTF();
			role.m_grade = dis.readInt();
			role.m_vocation = dis.readByte();
//			role.m_faction = dis.readByte();
			role.m_online = true;
			switch (type) {
				case SOCIAL_TYPE_FRIEND:
					m_social_friend_list.add(role);
					//好友
					if (flag == true) {
						if (m_social_friend_list == null) {
							return;
						}
						m_si_listBox[0].removeAllSubItem();
						refreshFriend();
					}
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
							"添加好友成功");
					break;
				case SOCIAL_TYPE_BLACKLIST:
					m_social_black_list.add(role);
					if (m_social_black_list == null) {
						return;
					}
					if (flag == false) {
						return;
					}
					m_si_listBox[2].removeAllSubItem();
					refreshBlack();
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
							"添加黑名单成功");
					break;
			}
		}
		else {
			Tools.debugPrintln("读取添加玩家失败 : ");
		}
	}

	/**
	 * 读取删除玩家
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialDelete(DataInputStream dis) throws IOException
	{
		byte state = dis.readByte();
		if (state == 1) {
			byte type = dis.readByte();
			long id = dis.readLong();
			switch (type) {
				case SOCIAL_TYPE_FRIEND:
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
							"您已经与对方解除好友关系");
					int sizef = m_social_friend_list.size();
					for (int i = 0; i < sizef; i++) {
						long roleID = ((SimpleRole) m_social_friend_list.elementAt(i)).m_gameID;
						if (id == roleID) {
							m_social_friend_list.removeElementAt(i);
							break;
						}
					}
					//好友
					if (m_social_friend_list == null) {
						return;
					}
					m_si_listBox[0].removeAllSubItem();
					refreshFriend();
					break;
				case SOCIAL_TYPE_BLACKLIST:
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
							"您已经将对方移出黑名单");
					int sizeb = m_social_black_list.size();
					for (int i = 0; i < sizeb; i++) {
						long roleID = ((SimpleRole) m_social_black_list.elementAt(i)).m_gameID;
						if (id == roleID) {
							m_social_black_list.removeElementAt(i);
							break;
						}
					}

					if (m_social_black_list == null) {
						return;
					}
					m_si_listBox[2].removeAllSubItem();
					refreshBlack();

					break;
			}
		}
		else {
			Tools.debugPrintln("读取删除玩家异常 : ");
		}
	}

	/**
	 * 添加好友确认信息
	 * 
	 * @param dis
	 */
	public void recvSocialConfirmation(DataInputStream dis)
			throws IOException
	{
		byte state = dis.readByte(); //0失败 1成功   
		if (state == 1) {
			final SimpleRole role = new SimpleRole();
			role.m_gameID = dis.readLong();
			role.m_name = dis.readUTF();
			role.m_grade = dis.readInt();
			role.m_vocation = dis.readByte();
			final DWMessageBox socialmb = new DWMessageBox("好友邀请", role.m_name + "  加你成为好友");
			socialmb.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (socialmb.getResult() == DWMessageBox.SOFTKEY_OK) {
						DWControlsManager.getInstance().removeControl(socialmb);
						DWGameManager.getInstance().getSendMessage().sendSocialConfirmation((byte) 1, role.m_gameID);
					}
					else if (socialmb.getResult() == DWMessageBox.SOFTKEY_BACK) {
						DWGameManager.getInstance().getSendMessage().sendSocialConfirmation((byte) 0, role.m_gameID);
						DWControlsManager.getInstance().removeControl(socialmb);
					}
				}
			});
			DWControlsManager.getInstance().addControl(socialmb);
		}
	}

	/**
	 * 读取仇敌界面
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialEnemyList(DataInputStream dis)
			throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_社交);
		Vector<SimpleRole> enemyList = new Vector<SimpleRole>();
		byte state = dis.readByte(); //当前状态
		Tools.debugPrintln("---------chou  di----state=" + state);
		if (state == 1) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, "页号错误");
			return;
		}
		short totalPage = dis.readShort(); //总页数

		if (totalPage < 0) {
			return;
		}
		short currentPage = dis.readShort(); //当前页数

		m_enemy_currentPage = currentPage;
		m_enemy_totalPage = totalPage;
		if (m_enemy_totalPage == 0) {
			m_enemy_totalPage = 1;
		}

		short enemyNum = dis.readShort();// 仇敌数量		
		Tools.debugPrintln("-----------choudi ye ma--------------------" + m_enemy_totalPage + "  " + enemyNum);
		for (int i = 0; i < enemyNum; i++) {
			SimpleRole role = new SimpleRole();

			role.m_gameID = dis.readLong();
			role.m_name = dis.readUTF();
			role.m_is_Locked = dis.readByte() == 1 ? true : false;// 是否 锁定 0 未锁定
			role.m_HatredDegrees = dis.readUTF(); // 仇恨度
			Tools.debugPrintln("m_HatredDegrees = " + role.m_HatredDegrees + ";name=" + role.m_name);
			// 1 锁定
			role.m_online = dis.readByte() == 1 ? true : false;// 是否在线 0离线 1在线
			Tools.debugPrintln("online = " + role.m_online);
			Tools.debugPrintln("id = " + role.m_gameID);
			Tools.debugPrintln("name = " + role.m_name);

			if (role.m_online) {
				role.m_grade = dis.readShort(); // 等级
			}

			enemyList.addElement(role);
		}
		m_social_enemy_list = enemyList;

		//仇敌
		if (m_social_enemy_list == null) {
			DWGameManager.getInstance().showToast("您还没有仇敌！", Toast.LENGTH_SHORT);
			return;
		}
		else {
			if (m_si_listBox[1] != null) {
				m_si_listBox[1].removeAllSubItem();
			}
			for (int i = 0; i < m_social_enemy_list.size(); i++) {
				SimpleRole sr = m_social_enemy_list.get(i);
				if (sr.m_online == true) {
					m_choudi_si[i] = new DWListSubItem();

					if (DWGameManager.AdpaterType == 2) {
						m_choudi_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
						m_choudi_textBox[i][1] = new DWTextbox(sr.m_HatredDegrees, DWGameManager.Screen_Width * 9 / 80);
						m_choudi_textBox[i][2] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 8 / 80);
						m_choudi_textBox[i][3] = new DWTextbox("" + sr.m_is_Locked, DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_choudi_textBox[i][0] = new DWTextbox(sr.m_name, 130);
						m_choudi_textBox[i][1] = new DWTextbox(sr.m_HatredDegrees, 90);
						m_choudi_textBox[i][2] = new DWTextbox("" + sr.m_grade, 80);
						m_choudi_textBox[i][3] = new DWTextbox("" + sr.m_is_Locked, 80);
					}
					if (sr.m_is_Locked == false) {
						m_choudi_textBox[i][3].setText("否");
					}
					else if (sr.m_is_Locked == true) {
						m_choudi_textBox[i][3].setText("是");
					}
				}
				else {
					m_choudi_si[i] = new DWListSubItem();

					if (DWGameManager.AdpaterType == 2) {
						m_choudi_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
								DWGameManager.Screen_Width * 13 / 80);
						m_choudi_textBox[i][1] = new DWTextbox("<mark c=818080>" + sr.m_HatredDegrees + "</mark>",
								DWGameManager.Screen_Width * 9 / 80);
						m_choudi_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>",
								DWGameManager.Screen_Width * 8 / 80);
						m_choudi_textBox[i][3] = new DWTextbox("<mark c=818080>--</mark>",
								DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_choudi_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
						m_choudi_textBox[i][1] = new DWTextbox("<mark c=818080>" + sr.m_HatredDegrees + "</mark>", 90);
						m_choudi_textBox[i][2] = new DWTextbox("<mark c=818080>--</mark>", 80);
						m_choudi_textBox[i][3] = new DWTextbox("<mark c=818080>--</mark>", 80);
					}
				}

				m_choudi_textBox[i][0].setNearAnchor(m_choudi_si[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_choudi_textBox[i][1].setNearAnchor(m_choudi_textBox[i][0], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_choudi_textBox[i][2].setNearAnchor(m_choudi_textBox[i][1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_choudi_textBox[i][3].setNearAnchor(m_choudi_textBox[i][2], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

				m_choudi_si[i].addControls(m_choudi_textBox[i][0]);
				m_choudi_si[i].addControls(m_choudi_textBox[i][1]);
				m_choudi_si[i].addControls(m_choudi_textBox[i][2]);
				m_choudi_si[i].addControls(m_choudi_textBox[i][3]);
				m_si_listBox[1].addSubItem(m_choudi_si[i]);

			}
			m_page_str[1] = "" + (m_enemy_currentPage + 1) + "/" + m_enemy_totalPage;
			m_tb_page[1].setText(m_page_str[1]);
		}

	}

	/**
	 * 查看仇敌详细信息
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialEnemyInfo(DataInputStream dis)
			throws IOException
	{

	}

	/**
	 * 仇敌的具体位置
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialEnemyPosition(DataInputStream dis)
			throws IOException
	{
		short state = dis.readShort();// 0失败1成功
		String msg = dis.readUTF(); // 失败有
		if (state == 0) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, msg);
			return;
		}
		String location = dis.readUTF(); // 仇敌具体位置
		String name = dis.readUTF();
		final DWMessageBox socialmb = new DWMessageBox("", name + "当前所在的位置： " + location);
		socialmb.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (socialmb.getResult() == DWMessageBox.SOFTKEY_OK) {
					DWControlsManager.getInstance().removeControl(socialmb);
				}
				else if (socialmb.getResult() == DWMessageBox.SOFTKEY_BACK) {
					DWControlsManager.getInstance().removeControl(socialmb);
				}
			}
		});
		DWControlsManager.getInstance().addControl(socialmb);
	}

	/**
	 * 删除仇敌
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialEnemyDelete(DataInputStream dis) throws IOException
	{
		short state = dis.readShort(); // 0失败1成功
		String msg = dis.readUTF(); // 失败有
		long enemyID = dis.readLong();// 仇敌ＩＤ
		if (state == 0) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, msg);
		}
		else if (state == 1) {
			Vector list = m_social_enemy_list;
			int size = list.size();
			for (int i = 0; i < size; i++) {
				long roleID = ((SimpleRole) list.elementAt(i)).m_gameID;
				if (enemyID == roleID) {
					list.removeElementAt(i);
					break;
				}
			}
		}
		//仇敌
		if (m_social_enemy_list == null) {
			DWGameManager.getInstance()
					.showToast("您还没有仇敌！", Toast.LENGTH_SHORT);
			return;
		}
		else {
			if (m_si_listBox[1] != null) {
				m_si_listBox[1].removeAllSubItem();
			}
			for (int i = 0; i < m_social_enemy_list.size(); i++) {
				SimpleRole sr = m_social_enemy_list.get(i);
				if (sr.m_online == true) {
					m_choudi_si[i] = new DWListSubItem();

					if (DWGameManager.AdpaterType == 2) {
						m_choudi_textBox[i][0] = new DWTextbox(sr.m_name, DWGameManager.Screen_Width * 13 / 80);
						m_choudi_textBox[i][1] = new DWTextbox(sr.m_HatredDegrees, DWGameManager.Screen_Width * 9 / 80);
						m_choudi_textBox[i][2] = new DWTextbox("" + sr.m_grade, DWGameManager.Screen_Width * 8 / 80);
						m_choudi_textBox[i][3] = new DWTextbox("" + sr.m_is_Locked, DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_choudi_textBox[i][0] = new DWTextbox(sr.m_name, 130);
						m_choudi_textBox[i][1] = new DWTextbox(sr.m_HatredDegrees, 90);
						m_choudi_textBox[i][2] = new DWTextbox("" + sr.m_grade, 80);
						m_choudi_textBox[i][3] = new DWTextbox("" + sr.m_is_Locked, 80);
					}
					if (sr.m_is_Locked == false) {
						m_choudi_textBox[i][3].setText("否");
					}
					else if (sr.m_is_Locked == true) {
						m_choudi_textBox[i][3].setText("是");
					}
				}
				else {
					m_choudi_si[i] = new DWListSubItem();

					if (DWGameManager.AdpaterType == 2) {
						m_choudi_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>",
								DWGameManager.Screen_Width * 13 / 80);
						m_choudi_textBox[i][1] = new DWTextbox("<mark c=818080>" + sr.m_HatredDegrees + "</mark>",
								DWGameManager.Screen_Width * 9 / 80);
						m_choudi_textBox[i][2] = new DWTextbox("<mark c=818080>" + sr.m_grade + "</mark>",
								DWGameManager.Screen_Width * 8 / 80);
						m_choudi_textBox[i][3] = new DWTextbox("<mark c=818080>" + sr.m_is_Locked + "</mark>",
								DWGameManager.Screen_Width * 8 / 80);
					}
					else {
						m_choudi_textBox[i][0] = new DWTextbox("<mark c=818080>" + sr.m_name + "</mark>", 130);
						m_choudi_textBox[i][1] = new DWTextbox("<mark c=818080>" + sr.m_HatredDegrees + "</mark>", 90);
						m_choudi_textBox[i][2] = new DWTextbox("<mark c=818080>" + sr.m_grade + "</mark>", 80);
						m_choudi_textBox[i][3] = new DWTextbox("<mark c=818080>" + sr.m_is_Locked + "</mark>", 80);
					}
					if (sr.m_is_Locked == false) {
						m_choudi_textBox[i][3].setText("否");
					}
					else if (sr.m_is_Locked == true) {
						m_choudi_textBox[i][3].setText("是");
					}
				}

				m_choudi_textBox[i][0].setNearAnchor(m_choudi_si[i],
						Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_choudi_textBox[i][1].setNearAnchor(m_choudi_textBox[i][0],
						Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_choudi_textBox[i][2].setNearAnchor(m_choudi_textBox[i][1],
						Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_choudi_textBox[i][3].setNearAnchor(m_choudi_textBox[i][2],
						Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

				m_choudi_si[i].addControls(m_choudi_textBox[i][0]);
				m_choudi_si[i].addControls(m_choudi_textBox[i][1]);
				m_choudi_si[i].addControls(m_choudi_textBox[i][2]);
				m_choudi_si[i].addControls(m_choudi_textBox[i][3]);
				m_si_listBox[1].addSubItem(m_choudi_si[i]);

			}
			m_page_str[1] = "" + (m_enemy_currentPage + 1) + "/"
					+ m_enemy_totalPage;
			m_tb_page[1].setText(m_page_str[1]);
		}

	}

	/**
	 * 发布通缉令
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialEnemyWanted(DataInputStream dis)
			throws IOException
	{
		//DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_默认);
		Byte state = dis.readByte(); // 0 失败 1成功		
		String msg = "null";
		if (state == 0) {
			msg = "发布成功";
		}
		else if (state == 1) {
			msg = "通缉失败，金钱不足";
		}
		else if (state == 2) {
			msg = "通缉失败，元宝不足";
		}
		else if (state == 3) {
			msg = "通缉失败，发送数量达到上限";
		}
		else if (state == 4) {
			msg = "通缉失败，不能同时通缉同一个人";
		}
		else if (state == 5) {
			msg = "通缉失败，同阵营不能通缉";
		}
		else if (state == 6) {
			msg = "通缉失败，等级限制不够";
		}
		else if (state == 7) {
			msg = "通缉失败，发布人异常";
		}
		else if (state == 8) {
			msg = "通缉失败，通缉目标不在线";
		}
		else if (state == 9) {
			msg = "通缉失败，目标今天已被通缉";
		}
		else if (state == 10) {
			msg = "通缉失败，元宝通缉需要《通缉令牌》道具";
			UIWindows.getInstance().m_warrant.shoptongji();
		}
		Tools.debugPrintln("state:" + state);
		DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, msg);
	}

	/**
	 * 锁定仇敌
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvSocialEnemyLock(DataInputStream dis)
			throws IOException
	{
		short state = dis.readShort(); // 0失败1成功
		String msg = dis.readUTF(); // 失败有
		long m_id = dis.readLong(); // 请求锁定玩家的ID
		Vector list = m_social_enemy_list;
		if (state == 1) {
			int size = list.size();
			for (int i = 0; i < size; i++) {
				SimpleRole role = (SimpleRole) list.elementAt(i);
				if (m_id == role.m_gameID) {
					role.m_is_Locked = true;
				}
			}
		}
		else {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, msg);
		}
	}

	public void logic()
	{
//		showTime();
		timeCountDown();

	}

	/**
	 * 师徒
	 */
	//徒弟未拜师
	private DWTextbox m_pupil_textBox = null;
	private DWButton m_pupil_button = null;
	private DWTextbox m_pupil_time = null;
	//徒弟已经拜师
	private DWAnimationBox m_haveTeacher_ab = null;
	private Resource mUserResource = new Resource();
	private Role m_teacher_role = null;
	private DWTextbox m_haveTeacher_name = null;
	private DWTextbox m_haveTeacher_lv = null;
	private DWTextbox m_haveTeacher_zhiye = null;
	private DWButton m_haveTeacher_button01 = null;
	private DWButton m_haveTeacher_button02 = null;
	private DWTextbox m_haveTeacher_chuangong = null;
	//中间阶段
	private DWTextbox m_doNothings_textBox = null;
	private DWButton m_doNothings_button = null;
	//收徒阶段
	private DWTextbox m_isTeacher_textBox = null;
	private DWButton m_isTecher_button01 = null;
	private DWButton m_isTecher_button02 = null;
	//师父阶段
	private DWTextbox m_teacher_label01 = null;
	private DWTextbox m_teacher_label02 = null;
	private DWTextbox m_teacher_label03 = null;
	private DWTextbox m_teacher_label04 = null;
	private DWTextbox m_teacher_label05 = null;
	private DWListbox m_teacher_listBox = null;
	private DWListSubItem[] m_teacher_item;
	private DWTextbox[] m_item_name;
	private DWTextbox[] m_item_lv;
	private DWTextbox[] m_item_chuangong;
	private DWTextbox[] m_item_shanchu;
	private DWTextbox[] m_item_chakan;
	private DWTextbox m_teacher_shoutu = null;
	private DWTextbox m_teacher_vip = null;
	private DWButton m_teacher_button01 = null;
	private DWButton m_teacher_button02 = null;
	private DWTextbox m_teacher_time = null;

	private DWButton m_tuijian_Button = null;//推荐按钮

	private void refresh()
	{
		if (m_si_tabPage[5] != null) {
			m_si_tabPage[5].removeAllControl();
		}
		m_pupil_textBox = null;
		m_pupil_button = null;
		//徒弟已经拜师
		m_haveTeacher_ab = null;
		m_teacher_role = null;
		m_haveTeacher_name = null;
		m_haveTeacher_lv = null;
		m_haveTeacher_zhiye = null;
		m_haveTeacher_button01 = null;
		m_haveTeacher_button02 = null;
		m_haveTeacher_chuangong = null;
		//中间阶段
		m_doNothings_textBox = null;
		m_doNothings_button = null;
		//收徒阶段
		m_isTeacher_textBox = null;
		m_isTecher_button01 = null;
		m_isTecher_button02 = null;
		//师父阶段
		m_teacher_label01 = null;
		m_teacher_label02 = null;
		m_teacher_label03 = null;
		m_teacher_label04 = null;
		m_teacher_listBox = null;

		m_teacher_shoutu = null;
		m_teacher_vip = null;
		m_teacher_button01 = null;
		m_teacher_button02 = null;
	}

	private void teacherAndPupil(int staus)
	{

		if (staus == 1) {//徒弟未拜师
			m_si_background.setShow(false);
			m_si_backgroundRight.setShow(false);

			String str = "在您" + m_pupil_minLv + "-" + m_pupil_maxLv + "级阶段内，您可以拜一位级别高于" + m_teacher_minLv
					+ "级的角色为师父`弟子每日可以通过师父的传功取得大量经验。";
			m_pupil_textBox = new DWTextbox(str, m_si_tc.getShowWidth() - 100);
			m_pupil_textBox.setNearAnchor(m_si_tabPage[5], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 50);
			m_si_tabPage[5].addControls(m_pupil_textBox);

			m_pupil_button = new DWButton("我要拜师", m_si_bm[m_si_add]);
			m_pupil_button.setShow(false);
			m_pupil_button.setDownImage(m_si_addxia);
			m_pupil_button.setNearAnchor(m_si_tabPage[5], Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -50);
			m_si_tabPage[5].addControls(m_pupil_button);

			m_tuijian_Button = new DWButton("推荐师傅", m_si_bm[m_si_add]);
			m_tuijian_Button.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					UIWindows.getInstance().m_tuijian.open(UITuiJian.TUIJIAN_SHIFU);
				}
			});
			m_tuijian_Button.setDownImage(m_si_addxia);
			if (staus != 1) {
				m_tuijian_Button.setTouch(false);
			}
			else {
				m_tuijian_Button.setTouch(true);
			}
			m_tuijian_Button.setNearAnchor(m_si_tabPage[5], Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -50);
			m_si_tabPage[5].addControls(m_tuijian_Button);

			m_pupil_time = new DWTextbox("");
			m_pupil_time.setNearAnchor(m_pupil_textBox, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 100);
			m_si_tabPage[5].addControls(m_pupil_time);
		}
		else if (staus == 2) {
			m_si_background.setShow(true);
			m_si_backgroundRight.setShow(true);

			m_haveTeacher_ab = new DWAnimationBox(m_teacher_role);
			m_haveTeacher_ab.setNearAnchor(m_si_tabPage[5], Tools.LEFT_TOP, Tools.LEFT_TOP, 30, 30);
			m_si_tabPage[5].addControls(m_haveTeacher_ab);

			m_haveTeacher_name = new DWTextbox("名称：" + m_teacher_name);
			m_haveTeacher_name.setNearAnchor(m_si_tabPage[5], Tools.LEFT_TOP, Tools.LEFT_TOP, 120, 30);
			m_si_tabPage[5].addControls(m_haveTeacher_name);

			m_haveTeacher_lv = new DWTextbox("等级：" + m_teacher_lv);
			m_haveTeacher_lv.setNearAnchor(m_haveTeacher_name, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 10);
			m_si_tabPage[5].addControls(m_haveTeacher_lv);

			m_haveTeacher_zhiye = new DWTextbox("职业：" + m_teacher_job);
			m_haveTeacher_zhiye.setNearAnchor(m_haveTeacher_lv, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 10);
			m_si_tabPage[5].addControls(m_haveTeacher_zhiye);

			m_haveTeacher_button01 = new DWButton("请求传功", m_si_bm[m_si_add]);
			m_haveTeacher_button01.setTouch(true);
			m_haveTeacher_button01.addListener(m_listener_chuangong);
			if (m_isChuan == 2) {
				m_haveTeacher_button01.setName("已传完功");
				m_haveTeacher_button01.setTouch(false);
				Tools.debugPrintln("传功m_ischuan=" + m_isChuan);
				m_haveTeacher_button01.setBackground(m_si_addxia, true);
			}
			m_haveTeacher_button01.setDownImage(m_si_addxia);
			m_haveTeacher_button01.setNearAnchor(m_si_tabPage[5], Tools.LEFT_TOP, Tools.HCENTER_TOP, 150, 30);
			m_si_tabPage[5].addControls(m_haveTeacher_button01);

			m_haveTeacher_button02 = new DWButton("叛出师门", m_si_bm[m_si_add]);
			m_haveTeacher_button02.addListener(m_listener_pantao);
			m_haveTeacher_button02.setDownImage(m_si_addxia);
			m_haveTeacher_button02.setNearAnchor(m_haveTeacher_button01, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 50);
			m_si_tabPage[5].addControls(m_haveTeacher_button02);

			String str = "每日师父均可为弟子传功一次`达到" + m_pupil_leaveLv + "级后，弟子会自动出师";
			m_haveTeacher_chuangong = new DWTextbox(str, 300);
			m_haveTeacher_chuangong.setNearAnchor(m_haveTeacher_button02, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0,
					50);
			m_si_tabPage[5].addControls(m_haveTeacher_chuangong);

		}
		else if (staus == 3) {
			m_si_background.setShow(false);
			m_si_backgroundRight.setShow(false);
			String str1 = Arrays.toString(m_libao);
			String str = "当你成长为" + m_teacher_minLv + "级，就可以收徒弟了。`师父通过每日传功可以获得修为。`当徒弟成长为" + str1 + "级时会分别给师父谢师礼包`徒弟达到"
					+ m_pupil_xieshi + "级后可以出师、出师后师父可以获得丰厚的出师礼包。";
			m_doNothings_textBox = new DWTextbox(str, m_si_tc.getShowWidth() - 100);
			m_doNothings_textBox.setNearAnchor(m_si_tabPage[5], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 50);
			m_si_tabPage[5].addControls(m_doNothings_textBox);

			m_doNothings_button = new DWButton("传道恩师", m_si_bm[m_si_add]);
			m_doNothings_button.addListener(m_listener_xueyi);
			m_doNothings_button.setDownImage(m_si_addxia);
			m_doNothings_button.setNearAnchor(m_si_tabPage[5], Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -50);
			m_si_tabPage[5].addControls(m_doNothings_button);

		}
		else if (staus == 4) {
			m_si_background.setShow(false);
			m_si_backgroundRight.setShow(false);
			String str1 = Arrays.toString(m_libao);
			String str = "你现在可以招收" + m_pupil_num + "名徒弟。`师父通过每日传功可以获得修为。`当弟子成长为" + str1 + "级时会分别给师父谢师礼包`徒弟达到"
					+ m_pupil_xieshi + "级后可以出师、出师后师父可以获得丰厚的出师礼包。";
			m_isTeacher_textBox = new DWTextbox(str, m_si_tc.getShowWidth() - 100);
			m_isTeacher_textBox.setNearAnchor(m_si_tabPage[5], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 50);
			m_si_tabPage[5].addControls(m_isTeacher_textBox);

			m_isTecher_button01 = new DWButton("传道恩师", m_si_bm[m_si_add]);
			m_isTecher_button01.addListener(m_listener_xueyi);
			m_isTecher_button01.setDownImage(m_si_addxia);
			m_isTecher_button01.setNearAnchor(m_isTeacher_textBox, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 50, 100);
			m_si_tabPage[5].addControls(m_isTecher_button01);

			m_isTecher_button02 = new DWButton("出师弟子", m_si_bm[m_si_add]);
			m_isTecher_button02.addListener(m_listener_taoli);
			m_isTecher_button02.setDownImage(m_si_addxia);
			m_isTecher_button02.setNearAnchor(m_isTeacher_textBox, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 100);
			m_si_tabPage[5].addControls(m_isTecher_button02);

			m_tuijian_Button = new DWButton("推荐弟子", m_si_bm[m_si_add]);
			m_tuijian_Button.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (m_pupil_num > 0) {
						UIWindows.getInstance().m_tuijian.open(UITuiJian.TUIJIAN_TUDI);
					}
					else {
						DWGameManager.getInstance()
								.addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您的徒弟已经达到上限，无法再收徒。");
					}
				}
			});
			m_tuijian_Button.setDownImage(m_si_addxia);
			m_tuijian_Button.setNearAnchor(m_isTeacher_textBox, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 100);
			m_si_tabPage[5].addControls(m_tuijian_Button);

			m_pupil_time = new DWTextbox("", m_isTeacher_textBox.getShowWidth());
			m_pupil_time.setNearAnchor(m_isTeacher_textBox, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 50);
			m_si_tabPage[5].addControls(m_pupil_time);
		}
		else if (staus == 5) {

			m_teacher_label01 = new DWTextbox("姓名", 200);
//			m_teacher_label01.setFont(DWFont.getFont(20));
//			m_teacher_label01.setShowWideHigh(200, 20);
//			m_teacher_label01.setShowBackground(false);
//			m_teacher_label01.setTextColor(Color.WHITE);
			m_teacher_label01.setNearAnchor(m_si_tabPage[5], Tools.LEFT_TOP, Tools.LEFT_TOP, 30, 10);
			m_si_tabPage[5].addControls(m_teacher_label01);

			m_teacher_label02 = new DWTextbox("等级", 60);
//			m_teacher_label02.setFont(DWFont.getFont(20));
//			m_teacher_label02.setShowWideHigh(60, 20);
//			m_teacher_label02.setShowBackground(false);
//			m_teacher_label02.setTextColor(Color.WHITE);
			m_teacher_label02.setNearAnchor(m_teacher_label01, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_si_tabPage[5].addControls(m_teacher_label02);

			m_teacher_label03 = new DWTextbox("传功", 80);
//			m_teacher_label03.setFont(DWFont.getFont(20));
//			m_teacher_label03.setShowWideHigh(80, 20);
//			m_teacher_label03.setShowBackground(false);
//			m_teacher_label03.setTextColor(Color.WHITE);
			m_teacher_label03.setNearAnchor(m_teacher_label02, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_si_tabPage[5].addControls(m_teacher_label03);

			m_teacher_label04 = new DWTextbox("驱逐", 80);
//			m_teacher_label04.setFont(DWFont.getFont(20));
//			m_teacher_label04.setShowWideHigh(80, 20);
//			m_teacher_label04.setShowBackground(false);
//			m_teacher_label04.setTextColor(Color.WHITE);
			m_teacher_label04.setNearAnchor(m_teacher_label03, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_si_tabPage[5].addControls(m_teacher_label04);

			m_teacher_label05 = new DWTextbox("查看", 80);
//			m_teacher_label05.setFont(DWFont.getFont(20));
			m_teacher_label05.setNearAnchor(m_teacher_label04, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_si_tabPage[5].addControls(m_teacher_label05);

			if (DWGameManager.AdpaterType == 2) {
				m_teacher_listBox = new DWListbox(m_teacher_label01.getShowWidth() + m_teacher_label02.getShowWidth()
						+ m_teacher_label03.getShowWidth() + m_teacher_label04.getShowWidth()
						+ m_teacher_label05.getShowWidth(), m_teacher_label05.getShowHeight() * 10);
			}
			else {
				m_teacher_listBox = new DWListbox(m_teacher_label01.getShowWidth() + m_teacher_label02.getShowWidth()
						+ m_teacher_label03.getShowWidth() + m_teacher_label04.getShowWidth()
						+ m_teacher_label05.getShowWidth(), 250);
			}
			m_teacher_listBox.removeAllSubItem();
			m_teacher_listBox.setShowBackgroundRect(false);
			m_teacher_listBox.setNearAnchor(m_teacher_label01, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 0);
			m_si_tabPage[5].addControls(m_teacher_listBox);

			m_teacher_item = new DWListSubItem[m_pupil_list.size()];
			m_item_name = new DWTextbox[m_pupil_list.size()];
			m_item_lv = new DWTextbox[m_pupil_list.size()];
			m_item_chuangong = new DWTextbox[m_pupil_list.size()];
			m_item_shanchu = new DWTextbox[m_pupil_list.size()];
			m_item_chakan = new DWTextbox[m_pupil_list.size()];
			for (int i = 0; i < m_pupil_list.size(); i++) {
				SimpleRole sr = m_pupil_list.get(i);
				final SimpleRole srole = sr;
				final int index = i;
				m_teacher_item[i] = new DWListSubItem();
				m_item_name[i] = new DWTextbox(sr.m_name, m_teacher_label01.getShowWidth());
//				m_item_name[i].setFont(DWFont.getFont(20));
				m_item_lv[i] = new DWTextbox(String.valueOf(sr.m_grade), m_teacher_label02.getShowWidth());
//				m_item_lv[i].setFont(DWFont.getFont(20));
				if (sr.m_grade < 0) {
					m_item_name[i].setText("<mark c=818080>" + sr.m_name + "</mark>");
					m_item_lv[i].setText("<mark c=818080>--</mark>");
				}
				m_item_chuangong[i] = new DWTextbox("传功", m_teacher_label03.getShowWidth());
//				m_item_chuangong[i].setFont(DWFont.getFont(20));
				if (sr.m_isChuanGong == 1) {
					m_item_chuangong[i].setText("传功");
				}
				else {
					m_item_chuangong[i].setText("已传");
				}
				m_item_shanchu[i] = new DWTextbox("驱逐", m_teacher_label04.getShowWidth());
//				m_item_shanchu[i].setFont(DWFont.getFont(20));
				m_item_chakan[i] = new DWTextbox("查看", m_teacher_label04.getShowWidth());
//				m_item_chakan[i].setFont(DWFont.getFont(20));
				m_item_name[i].setNearAnchor(m_teacher_item[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_item_lv[i].setNearAnchor(m_item_name[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_item_chuangong[i].setNearAnchor(m_item_lv[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_item_shanchu[i].setNearAnchor(m_item_chuangong[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_item_chakan[i].setNearAnchor(m_item_shanchu[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

				m_teacher_item[i].addControls(m_item_name[i]);
				m_teacher_item[i].addControls(m_item_lv[i]);
				m_teacher_item[i].addControls(m_item_chuangong[i]);
				m_teacher_item[i].addControls(m_item_shanchu[i]);
				m_teacher_item[i].addControls(m_item_chakan[i]);

				m_teacher_listBox.addSubItem(m_teacher_item[i]);

				m_item_chuangong[index].addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						final DWMessageBox mb = new DWMessageBox("提示", "你确认要为此徒弟传功？");
						DWControlsManager.getInstance().addControl(mb);
						mb.addListener(new DWListener() {

							public void OnDoubleClick()
							{
							}

							public void OnClick()
							{
								if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
									DWControlsManager.getInstance().removeControl(mb);
									DWGameManager.getInstance().getSendMessage().sendChuanGongQingQiu(srole.m_name);
								}
								else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
									DWControlsManager.getInstance().removeControl(mb);
								}

							}
						});

					}
				});

				m_item_shanchu[index].addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						final DWMessageBox mb = new DWMessageBox("提示", "将弟子逐出师门后，24小时内将不可以再次收徒！");
						DWControlsManager.getInstance().addControl(mb);
						mb.addListener(new DWListener() {

							public void OnDoubleClick()
							{
							}

							public void OnClick()
							{
								if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
									DWControlsManager.getInstance().removeControl(mb);
									DWGameManager.getInstance().getSendMessage()
											.sendBaiShiTongYong(TICHU, srole.m_name);
								}
								else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
									DWControlsManager.getInstance().removeControl(mb);
								}
							}
						});

					}
				});

				m_item_chakan[index].addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(srole.m_gameID);
					}
				});
			}

			m_teacher_shoutu = new DWTextbox("您还可以收徒" + m_pupil_num + "人");
			m_teacher_shoutu.setNearAnchor(m_teacher_listBox, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 10);
			m_si_tabPage[5].addControls(m_teacher_shoutu);

			m_teacher_vip = new DWTextbox("Vip" + (DWGameManager.getInstance().m_role.m_vip_lv + 1) + "可以收徒"
					+ m_pupil_vipNum);
			if (DWGameManager.getInstance().m_role.m_vip_lv == 6) {
				m_teacher_vip.setText("Vip" + DWGameManager.getInstance().m_role.m_vip_lv + "可以收徒" + m_pupil_vipNum);
			}

			m_teacher_vip.setNearAnchor(m_teacher_shoutu, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 0);
			m_si_tabPage[5].addControls(m_teacher_vip);

			m_teacher_button01 = new DWButton("传道恩师", m_si_bm[m_si_add]);
			m_teacher_button01.addListener(m_listener_xueyi);
			m_teacher_button01.setDownImage(m_si_addxia);
			if (DWGameManager.AdpaterType == 2) {
				m_teacher_button01.setNearAnchor(m_si_tabPage[5], Tools.LEFT_TOP, Tools.HCENTER_TOP, 180, 130);
			}
			else {
				m_teacher_button01.setNearAnchor(m_si_tabPage[5], Tools.LEFT_TOP, Tools.HCENTER_TOP, 180, 30);
			}
			m_si_tabPage[5].addControls(m_teacher_button01);

			m_teacher_button02 = new DWButton("出师弟子", m_si_bm[m_si_add]);
			m_teacher_button02.addListener(m_listener_taoli);
			m_teacher_button02.setDownImage(m_si_addxia);
			m_teacher_button02.setNearAnchor(m_teacher_button01, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 50);
			m_si_tabPage[5].addControls(m_teacher_button02);

			m_tuijian_Button = new DWButton("推荐弟子", m_si_bm[m_si_add]);
			m_tuijian_Button.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (m_pupil_num > 0) {
						UIWindows.getInstance().m_tuijian.open(UITuiJian.TUIJIAN_TUDI);
					}
					else {
						DWGameManager.getInstance()
								.addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您的徒弟已经达到上限，无法再收徒。");
					}
				}
			});
			m_tuijian_Button.setDownImage(m_si_addxia);
			m_tuijian_Button.setNearAnchor(m_teacher_button02, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 50);
			m_si_tabPage[5].addControls(m_tuijian_Button);

			m_pupil_time = new DWTextbox("", m_teacher_button02.getShowWidth());
			m_pupil_time.setNearAnchor(m_tuijian_Button, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 50);
			m_si_tabPage[5].addControls(m_pupil_time);
		}
	}

	//我的师父
	private DWFrame m_teacher_frame = null;
	private DWBackground m_teacher_background = null;
	private DWTitle m_teacher_title = null;
	private DWAnimationBox m_teacher_aBox = null;
	private DWTextbox m_teacher_teacherName = null;
	private DWTextbox m_teacher_teacherLv = null;
	private DWTextbox m_teacher_teacherJob = null;

	private void lookTeacher()
	{
		m_teacher_frame = new DWFrame(400, 200);
		m_teacher_title = new DWTitle("我的师父", m_teacher_frame);
		m_teacher_background = new DWBackground(m_teacher_frame.getShowWidth() - 50,
				m_teacher_frame.getShowHeight() - 50);
		m_teacher_background.setNearAnchor(m_teacher_frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_teacher_aBox = new DWAnimationBox(m_teacher_role);
		m_teacher_aBox.setNearAnchor(m_teacher_frame, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 30, 0);
		m_teacher_teacherName = new DWTextbox("名称：" + m_teacher_name);
		m_teacher_teacherName.setNearAnchor(m_teacher_aBox, Tools.LEFT_TOP, Tools.RIGHT_TOP, 10, 0);
		m_teacher_teacherLv = new DWTextbox("等级：" + m_teacher_lv);
		m_teacher_teacherLv.setNearAnchor(m_teacher_teacherName, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 10);
		m_teacher_teacherJob = new DWTextbox("职业：" + m_teacher_job);
		m_teacher_teacherJob.setNearAnchor(m_teacher_teacherLv, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 10);

		m_teacher_frame.addControl(m_teacher_background);
		m_teacher_frame.addControl(m_teacher_title);
		m_teacher_frame.addControl(m_teacher_aBox);
		m_teacher_frame.addControl(m_teacher_teacherName);
		m_teacher_frame.addControl(m_teacher_teacherLv);
		m_teacher_frame.addControl(m_teacher_teacherJob);
		DWControlsManager.getInstance().addControl(m_teacher_frame);
	}

	//我的徒弟
	private DWFrame m_pupil_frame = null;
	private DWBackground m_pupil_background = null;
	private DWTitle m_pupil_title = null;
	private DWListbox m_pupil_listBox = null;
	private DWTextbox m_pupil_labelName = null;
	private DWTextbox m_pupil_labelLv = null;
	private DWTextbox m_pupil_labelJob = null;
	private DWTextbox m_pupil_labelMoney = null;
	private DWListSubItem[] m_pupil_sub;
	private DWTextbox[] m_pupil_name;
	private DWTextbox[] m_pupil_lv;
	private DWTextbox[] m_pupil_zhiye;
	private DWTextbox[] m_pupil_money;
	Vector<SimpleRole> m_taoli_list = new Vector<SimpleRole>();

	private void lookPupil()
	{
		m_pupil_frame = new DWFrame(400, 300);
		m_pupil_title = new DWTitle("我的徒弟", m_pupil_frame);
		m_pupil_background = new DWBackground(m_pupil_frame.getShowWidth() - 50, m_pupil_frame.getShowHeight() - 50);
		m_pupil_background.setNearAnchor(m_pupil_frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_pupil_listBox = new DWListbox(m_pupil_background.getShowWidth() - 50, m_pupil_background.getShowHeight() - 75);
		m_pupil_listBox.setNearAnchor(m_pupil_background, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);

		m_pupil_labelName = new DWTextbox("姓名", 120);
		m_pupil_labelName.setFont(DWFont.getFont(20));
//		m_pupil_labelName.setShowWideHigh(120, 20);
//		m_pupil_labelName.setTextColor(Color.WHITE);
//		m_pupil_labelName.setShowBackground(false);
		m_pupil_labelName.setNearAnchor(m_pupil_listBox, Tools.LEFT_BOTTOM, Tools.LEFT_TOP, 0, 0);

		m_pupil_labelLv = new DWTextbox("等级", 50);
		m_pupil_labelLv.setFont(DWFont.getFont(20));
//		m_pupil_labelLv.setShowWideHigh(50, 20);
//		m_pupil_labelLv.setTextColor(Color.WHITE);
//		m_pupil_labelLv.setShowBackground(false);
		m_pupil_labelLv.setNearAnchor(m_pupil_labelName, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

		m_pupil_labelJob = new DWTextbox("职业", 50);
		m_pupil_labelJob.setFont(DWFont.getFont(20));
//		m_pupil_labelJob.setShowWideHigh(50, 20);
//		m_pupil_labelJob.setTextColor(Color.WHITE);
//		m_pupil_labelJob.setShowBackground(false);
		m_pupil_labelJob.setNearAnchor(m_pupil_labelLv, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

		m_pupil_labelMoney = new DWTextbox("财富", 80);
		m_pupil_labelMoney.setFont(DWFont.getFont(20));
//		m_pupil_labelMoney.setShowWideHigh(80, 20);
//		m_pupil_labelMoney.setTextColor(Color.WHITE);
//		m_pupil_labelMoney.setShowBackground(false);
		m_pupil_labelMoney.setNearAnchor(m_pupil_labelJob, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

		m_pupil_sub = new DWListSubItem[m_taoli_list.size()];
		m_pupil_name = new DWTextbox[m_taoli_list.size()];
		m_pupil_lv = new DWTextbox[m_taoli_list.size()];
		m_pupil_zhiye = new DWTextbox[m_taoli_list.size()];
		m_pupil_money = new DWTextbox[m_taoli_list.size()];

		for (int i = 0; i < m_taoli_list.size(); i++) {
			SimpleRole sr = m_taoli_list.get(i);
			m_pupil_sub[i] = new DWListSubItem();
			m_pupil_name[i] = new DWTextbox(sr.m_name, 120);
			m_pupil_name[i].setFont(DWFont.getFont(20));
			m_pupil_lv[i] = new DWTextbox(String.valueOf(sr.m_grade), 50);
			m_pupil_lv[i].setFont(DWFont.getFont(20));
			m_pupil_zhiye[i] = new DWTextbox("", 50);
			m_pupil_zhiye[i].setFont(DWFont.getFont(20));
			if (sr.m_vocations == 1) {
				m_pupil_zhiye[i].setText("剑客");
			}
			else if (sr.m_vocations == 2) {
				m_pupil_zhiye[i].setText("武者");
			}
			else if (sr.m_vocations == 3) {
				m_pupil_zhiye[i].setText("道士");
			}
			m_pupil_money[i] = new DWTextbox(String.valueOf(sr.m_money), 80);
			m_pupil_money[i].setFont(DWFont.getFont(20));
			if (sr.m_grade < 0) {
				m_pupil_lv[i].setText("--");
				m_pupil_zhiye[i].setText("--");
				m_pupil_money[i].setText("--");
			}

			m_pupil_name[i].setNearAnchor(m_pupil_sub[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
			m_pupil_lv[i].setNearAnchor(m_pupil_name[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_pupil_zhiye[i].setNearAnchor(m_pupil_lv[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
			m_pupil_money[i].setNearAnchor(m_pupil_zhiye[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);

			m_pupil_sub[i].addControls(m_pupil_name[i]);
			m_pupil_sub[i].addControls(m_pupil_lv[i]);
			m_pupil_sub[i].addControls(m_pupil_zhiye[i]);
			m_pupil_sub[i].addControls(m_pupil_money[i]);

			m_pupil_listBox.addSubItem(m_pupil_sub[i]);

		}

		m_pupil_frame.addControl(m_pupil_background);
		m_pupil_frame.addControl(m_pupil_title);
		m_pupil_frame.addControl(m_pupil_listBox);
		m_pupil_frame.addControl(m_pupil_labelName);
		m_pupil_frame.addControl(m_pupil_labelLv);
		m_pupil_frame.addControl(m_pupil_labelJob);
		m_pupil_frame.addControl(m_pupil_labelMoney);
		DWControlsManager.getInstance().addControl(m_pupil_frame);
	}

	//传功
	private DWListener m_listener_chuangong = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWGameManager.getInstance().getSendMessage().sendChuanGongQingQiu(m_teacher_name);
		}
	};
	//叛逃师门
	private DWListener m_listener_pantao = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			final DWMessageBox mb = new DWMessageBox("提示", "背叛师门后，将受到24小时内不能再次拜师的惩罚！");
			DWControlsManager.getInstance().addControl(mb);
			mb.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
						DWControlsManager.getInstance().removeControl(mb);
						DWGameManager.getInstance().getSendMessage().sendBaiShiTongYong(PANTAO, "");
					}
					else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
						DWControlsManager.getInstance().removeControl(mb);
					}

				}
			});

		}
	};
	//学艺天下（查看师父）
	private DWListener m_listener_xueyi = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWGameManager.getInstance().getSendMessage().sendBaiShiTongYong(XUEYI, "");
		}
	};
	//桃李天下（查看徒弟）
	private DWListener m_listener_taoli = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWGameManager.getInstance().getSendMessage().sendBaiShiTongYong(TAOLI, "");
		}
	};

	//处理时间
	public void showIsTime()
	{
		m_level_time--;
		if (m_level_time <= 0) {
			m_level_time = 0;
			if (m_pupil_time != null) {
				m_pupil_time.setShow(false);
				m_pupil_time.setText("");
			}
			return;
		}
		int hh = (int) m_level_time / 3600;
		int mm = (int) m_level_time % 3600 / 60;
		int ss = (int) m_level_time % 3600 % 60;
		if (m_pupil_time == null) {
			return;
		}
		if (hh == 0) {
			if (m_state == 1) {
				m_pupil_time.setText("<mark c=FF0000>因为背叛师门，您在" + mm + ":" + ss + "时间后才可再次拜师</mark>");
			}
			else if (m_state == 4 || m_state == 5) {
				m_pupil_time.setText("<mark c=FF0000>因为驱逐弟子，您在" + mm + ":" + ss + "时间后才可再次收徒</mark>");
			}
		}
		else {
			if (m_state == 1) {
				m_pupil_time.setText("<mark c=FF0000>因为背叛师门，您在" + hh + ":" + mm + ":" + ss + "时间后才可再次拜师</mark>");
			}
			else if (m_state == 4 || m_state == 5) {
				m_pupil_time.setText("<mark c=FF0000>因为驱逐弟子，您在" + hh + ":" + mm + ":" + ss + "时间后才可再次收徒</mark>");
			}
		}
		m_pupil_time.setShow(true);
	}

	long m_start_time = 0;
	long m_next_second = 0;

	public void timeCountDown()
	{
		if (m_start_time == 0) {
			m_start_time = System.currentTimeMillis();///开始倒计时时截取系统时间
			m_next_second = m_start_time + 1000;
		}
		long m_currrent_time = System.currentTimeMillis();
		if (m_currrent_time >= m_next_second) {
			showIsTime();
			m_start_time = m_next_second;
			m_next_second += 1000;
		}
	}

	public static final byte PANTAO = 1;// 判处师门
	public static final byte XUEYI = 2;//学艺之路
	public static final byte TAOLI = 3;//桃李天下
	public static final byte TICHU = 4;//踢出师门

	private int m_state = 0;
	private Vector<SimpleRole> m_pupil_list = new Vector<SimpleRole>();
	private int[] m_libao;
	private int m_pupil_minLv = 0;//徒弟最低等级
	private int m_pupil_maxLv = 0;//徒弟最高等
	private int m_teacher_minLv = 0;//老师最低等级
	private String m_teacher_name = null;
	private int m_teacher_lv = 0;
	private String m_teacher_job = null;
	private int m_isChuan = 0;
	private int m_pupil_leaveLv = 0;//徒弟出师级别
	private int m_pupil_xieshi = 0;//谢师礼包等级
	private int m_pupil_num = 0;
	private int m_pupil_vipNum = 0;
	private String[] m_taoli_str;
	private String m_taoli_job = null;
	public long m_shitu_id = 0;
	public static boolean m_shitu_isOpen = false;
	private long m_level_time = 0;

	/**
	 * 师徒界面
	 */
	public void recvPupilList(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		byte state = dis.readByte();
		m_state = state;
		Tools.debugPrintln("状态：" + state);
		if (state == 1) {
			int minLv = dis.readInt();//徒弟最低等级
			int maxLv = dis.readInt();//徒弟最高等级
			int leaveLv = dis.readInt();//徒弟出师级别
			int teacherLv = dis.readInt();//老师最低等级
//			long time = dis.readLong();
			m_pupil_minLv = minLv;
			m_pupil_maxLv = maxLv;
			m_teacher_minLv = teacherLv;

		}
		else if (state == 2) {
			m_teacher_role = new Role(mUserResource);
			String name = dis.readUTF();//老师名字
			byte chuan = dis.readByte();//1:可以传功 2：已经传授过了
			int leaveLv = dis.readInt();
			int lv = dis.readInt();//老师等级 -1为不在线
			Tools.debugPrintln("传功数值：" + chuan);

			if (lv < 0) {
				m_teacher_name = name;
				m_teacher_job = "--";
				m_teacher_lv = 0;
				m_isChuan = chuan;
				m_pupil_leaveLv = leaveLv;
				teacherAndPupil(m_state);
				return;
			}
			m_teacher_role.m_vocation = dis.readByte();//老师职业
			m_teacher_role.m_sex = dis.readByte();

			String[] strs = new String[5];
			for (int i = 0; i < 5; i++) {
				strs[i] = dis.readUTF();
			}
			m_teacher_role.initRoleAnims(mUserResource, strs);

			m_teacher_name = name;
			m_teacher_lv = lv;
			if (m_teacher_role.m_vocation == 1) {
				m_teacher_job = "剑客";
			}
			else if (m_teacher_role.m_vocation == 2) {
				m_teacher_job = "武者";
			}
			else if (m_teacher_role.m_vocation == 3) {
				m_teacher_job = "道士";
			}
			m_isChuan = chuan;
			m_pupil_leaveLv = leaveLv;

		}
		else if (state == 3) {
			int leaveLv = dis.readInt();//徒弟出师级别
			int teacher = dis.readInt();//老师最低级别
			byte size = dis.readByte();
			m_libao = new int[size];
			for (int i = 0; i < size; i++) {
				int libao = dis.readInt();
				m_libao[i] = libao;
			}
			int xieshi = dis.readInt();//徒弟谢师礼包等级

			m_pupil_leaveLv = leaveLv;
			m_teacher_minLv = teacher;
			m_pupil_xieshi = xieshi;

		}
		else if (state == 4) {
			byte num = dis.readByte();//可以收徒数
			int chushulibao = dis.readInt();//出师礼包

			byte size = dis.readByte();
			m_libao = new int[size];
			for (int i = 0; i < size; i++) {
				int libao = dis.readInt();
				m_libao[i] = libao;
			}
			int xieshi = dis.readInt();//徒弟谢师礼包等级
//			long time = dis.readLong();

			m_pupil_num = num;
			m_pupil_xieshi = xieshi;

		}
		else if (state == 5) {
			byte num = dis.readByte();//可以收徒数
			byte vipNum = dis.readByte();//vip可以收徒数
			byte size = dis.readByte();
			Vector<SimpleRole> m_social_list = new Vector<SimpleRole>();
			for (int i = 0; i < size; i++) {
				SimpleRole role = new SimpleRole();

				role.m_gameID = dis.readLong();
				role.m_name = dis.readUTF();
				role.m_grade = dis.readInt();
				role.m_isChuanGong = dis.readByte();//1：可传功 2：已传功
				m_social_list.addElement(role);
			}
//			long time = dis.readLong();
			m_pupil_list = m_social_list;

			m_pupil_num = num;
			m_pupil_vipNum = vipNum;
		}
		long time = dis.readLong();
		m_level_time = time / 1000;
		teacherAndPupil(m_state);
	}

	/**
	 * 接收拜师请求
	 * @param dis
	 * @throws IOException
	 */
	public void recvBaiShi(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		try {
			long gameid = dis.readLong();
			String name = dis.readUTF();
			int lv = dis.readInt();

			final long gameId = gameid;
			String str = null;
			if (lv < DWGameManager.getInstance().m_role.m_lv) {
				str = name + ",(" + lv + "级)，希望拜你为师，师父每日传功可以获得修为奖励，弟子成长后可以获得谢师礼包。";
			}
			else {
				str = name + ",(" + lv + "级)，希望收你为徒，师父每日传功可给予弟子大量经验，快速提升级别。";
			}
			final DWMessageBox mb = new DWMessageBox("提示", str);
			DWControlsManager.getInstance().addControl(mb);
			mb.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
						DWControlsManager.getInstance().removeControl(mb);
						DWGameManager.getInstance().getSendMessage().sendBaiShiJueDing(gameId, (byte) 1);
					}
					else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
						DWGameManager.getInstance().getSendMessage().sendBaiShiJueDing(gameId, (byte) 0);
						DWControlsManager.getInstance().removeControl(mb);
					}

				}
			});

		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	/**
	 * //接收师父是否接受
	 * @param dis
	 * @throws IOException
	 */
	public void recvHuiDa(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		try {
			byte staus = dis.readByte();
			String str = null;
			if (staus == 0) {
				str = "失败";
			}
			else if (staus == 1) {
				str = "拜师成功";
			}
			else if (staus == 2) {
				str = "解除师徒关系";
				m_si_background.setShow(false);
				m_si_backgroundRight.setShow(false);
				refresh();
				DWGameManager.getInstance().getSendMessage().sendBaiShiOpen();
			}
			else if (staus == 3) {
				str = "传功成功";
			}
			else if (staus == 4) {
				str = "弟子出师成功";
			}
			else if (staus == 5) {
				str = "成功";
			}
			else if (staus == 6) {
				str = "对方不在线";
			}
			else if (staus == 7) {
				str = "不够师父条件";
			}
			else if (staus == 8) {
				str = "师父可招收弟子数已满";
			}
			else if (staus == 9) {
				str = "自己师徒系统处在限制时间内";
			}
			else if (staus == 10) {
				str = "阵营不一致，不能建立师徒关系";
			}
			else if (staus == 11) {
				str = "已有师父，不能拜师";
			}
			else if (staus == 12) {
				str = "对方师徒系统处在限制时间内";
			}
			else if (staus == 13) {
				str = "对方不在线";
			}
			else if (staus == 14) {
				str = "对方否定您的请求";
			}
			else if (staus == 15) {
				str = "对方正在副本或者竞技场中";
			}
			else if (staus == 16) {
				str = "师父已经给弟子传过功";
			}
			else if (staus == 17) {
				str = "没有拜过师";
			}
			else if (staus == 18) {
				str = "没有出师弟子";
			}
			else if (staus == 19) {
				str = "已经存在师徒关系";
			}
			else if (staus == 20) {
				str = "对方拒绝了传功请求";
			}
			else if (staus == 21) {
				str = "传送到目标区域";
			}
			else if (staus == 22) {
				str = "师父每日收徒次数已达上限";
			}
			else if (staus == 23) {
				str = "正在传功";
			}
			else if (staus == 24) {
				str = "既不符合师傅条件，也不符合弟子条件";
			}
			else if (staus == 25) {
				str = "对方不够弟子条件";
			}
			else if (staus == 26) {
				str = "对方已有师傅";
			}
			else if (staus == 27) {
				str = "师傅拒绝对方请求拜师成功";
			}
			else if (staus == 28) {
				str = "师徒距离太远，不能传功";
			}
			else if (staus == 29) {
				str = "自己正在副本或者竞技场中，不能传功";
			}
			else if (staus == 50) {

			}

			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, str);

		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	/**
	 * //通用请求的返回 1 判处师门 2 学艺之路 3 桃李天下4.踢出师门
	 * @param dis
	 * @throws IOException
	 */
	public void recvTongYong(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		try {
			byte staus = dis.readByte();
			if (staus == 1) {
				byte sta = dis.readByte();
				String str = null;
				if (sta == 0) {
					str = "失败";
				}
				else {
					str = "成功";
				}
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, str);
			}
			else if (staus == 2) {
				m_teacher_role = new Role(mUserResource);
				String name = dis.readUTF();
				int lv = dis.readInt();
				m_teacher_role.m_vocation = dis.readByte();//老师职业
				if (lv < 0) {
//					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "师父不在线！");
					m_teacher_name = name;
					m_teacher_teacherLv.setText("师父不在线！");
					m_teacher_teacherJob.setText("");
					lookTeacher();
					return;
				}
				m_teacher_role.m_sex = dis.readByte();

				String[] strs = new String[5];
				for (int i = 0; i < 5; i++) {
					strs[i] = dis.readUTF();
				}
				m_teacher_role.initRoleAnims(mUserResource, strs);

				m_teacher_name = name;
				m_teacher_lv = lv;
				if (m_teacher_role.m_vocation == 1) {
					m_teacher_job = "剑客";
				}
				else if (m_teacher_role.m_vocation == 2) {
					m_teacher_job = "武者";
				}
				else if (m_teacher_role.m_vocation == 3) {
					m_teacher_job = "道士";
				}
				lookTeacher();

			}
			else if (staus == 3) {
				byte size = dis.readByte();
				if (size == 0) {
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您还没有收徒");
					return;
				}

				Vector<SimpleRole> m_social_list = new Vector<SimpleRole>();
				for (int i = 0; i < size; i++) {
					SimpleRole role = new SimpleRole();

					role.m_name = dis.readUTF();
					role.m_grade = dis.readInt();
					role.m_vocations = dis.readByte();
					role.m_money = dis.readLong();
					m_social_list.addElement(role);
				}
				m_taoli_list = m_social_list;

				lookPupil();

			}
			else if (staus == 4) {
				byte sta = dis.readByte();
				String str = null;
				if (sta == 0) {
					str = "失败";
				}
				else {
					str = "成功";
				}
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, str);
			}
		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	/*
	 * 传功
	 */
	public void recvChuanGong(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		try {
			long guid = dis.readLong();
			String name = dis.readUTF();
			int lv = dis.readInt();
//			byte chuangong = dis.readByte();
			final long guId = guid;
			final DWMessageBox mb = new DWMessageBox("传功请求", name + " " + lv + "级，请求传功，确定后，两人都将会被传送到凌霄殿进行。");
			DWControlsManager.getInstance().addControl(mb);
			mb.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
						DWGameManager.getInstance().getSendMessage().sendChuanGongYingDa(guId, (byte) 1);
						DWControlsManager.getInstance().removeControl(mb);
					}
					else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
						DWGameManager.getInstance().getSendMessage().sendChuanGongYingDa(guId, (byte) 0);
						DWControlsManager.getInstance().removeControl(mb);
					}

				}
			});

		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	/*
	 * 传功是否完成
	 */
	public void recvGetChuanGong(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		try {
			byte staus = dis.readByte();
			String str = null;
			if (staus == 0) {
				str = "传功失败";
			}
			else if (staus == 1) {
				str = "传功成功";
			}
			else if (staus == 2) {
				str = "角色不在线";
			}
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, str);
		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	/**
	 * 接收传功时间（同时在传完后返回一条指令）
	 */
	public void recvGetChuanGongTotal(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_师徒);
		try {
			long id = dis.readLong();
			byte total = dis.readByte();
			String str = dis.readUTF();
			m_shitu_id = id;
			m_shitu_isOpen = true;
			UIWindows.getInstance().m_main.setBarTotal(str, total * DWGameManager.FRAME_PER_SECOND);//DWGameManager.FRAME_PER_SECOND

		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	public static void openUISocialFriendToMail()
	{
		m_haoyou_name = 1;
		DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_FRIEND, 0, num);
	}

	public static void openUISocialFriendToHunYin()
	{
		m_haoyou_name = 2;
		DWGameManager.getInstance().getSendMessage().sendSocialList(SOCIAL_TYPE_FRIEND, 0, num);
	}

	/********************************* 队伍界面 *****************************************/
	private Bitmap m_bm_team = null;
	private DWButton m_button_zidong = null;
	private DWPopMenu m_menu_owmself = null;
	private String[] m_string_owmself = { "查看", "解散", "离开" };
	private DWPopMenu m_menu_ownother = null;
	private String[] m_string_ownother = { "查看", "加为好友", "踢出队伍", "转让队长", "解散队伍", "传入密音", "交易", "加为黑名单" };
	private DWPopMenu m_menu_otherown = null;
	private String[] m_string_otherown = { "查看", "退出" };
	private DWPopMenu m_menu_other = null;
	private String[] m_string_other = { "查看", "加为好友", "传入密音", "交易", "加为黑名单" };
	private int m_team_index = 0;

	//刷新我的队伍
	private void refreshMyTeam()
	{
		if (m_si_listBox[3] != null) {
			m_si_listBox[3].removeAllSubItem();
		}
		m_si_tabPage[3].removeControl(m_button_zidong);
		if (teamID == 0) {
			m_button_zidong = null;
			m_button_zidong = new DWButton("自动组队", m_bm_team);
			m_button_zidong.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWGameManager.getInstance().getSendMessage().sendTeamAutoCreate();
				}
			});
			m_button_zidong.setNearAnchor(m_si_listBox[3], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
			m_si_tabPage[3].addControls(m_button_zidong);

		}
		else {
			if (m_button_zidong != null) {
				m_si_tabPage[3].removeControl(m_button_zidong);
			}
			DWListSubItem[] m_item_team = new DWListSubItem[teamList.size()];
			DWTextbox[] m_text_name = new DWTextbox[teamList.size()];
			DWTextbox[] m_text_lv = new DWTextbox[teamList.size()];
			DWTextbox[] m_text_job = new DWTextbox[teamList.size()];
			for (int i = 0; i < teamList.size(); i++) {
				SimpleRole team = (SimpleRole) teamList.get(i);
				m_item_team[i] = new DWListSubItem();
				m_text_name[i] = new DWTextbox(team.m_name, 130);
				m_text_name[i].setFont(DWFont.getFont(20));
				m_text_lv[i] = new DWTextbox("" + team.m_grade, 130);
				m_text_lv[i].setFont(DWFont.getFont(20));
				m_text_job[i] = new DWTextbox("" + team.m_vocation, 130);
				m_text_job[i].setFont(DWFont.getFont(20));
				if (team.m_vocation == 1) {
					m_text_job[i].setText("剑客");
				}
				else if (team.m_vocation == 2) {
					m_text_job[i].setText("武者");
				}
				else if (team.m_vocation == 3) {
					m_text_job[i].setText("道士");
				}
				m_text_name[i].setNearAnchor(m_item_team[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_lv[i].setNearAnchor(m_text_name[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_text_job[i].setNearAnchor(m_text_lv[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_item_team[i].addControls(m_text_name[i]);
				m_item_team[i].addControls(m_text_lv[i]);
				m_item_team[i].addControls(m_text_job[i]);
				m_si_listBox[3].addSubItem(m_item_team[i]);
			}
		}
	}

	private DWListener m_listBox_team = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_si_listBox[3].getTouchIndex();
			m_team_index = index;
			SimpleRole m_team_role = (SimpleRole) teamList.get(m_team_index);
			Tools.debugPrintln("m_team_role==" + m_team_role.m_gameID + "-------"
					+ DWGameManager.getInstance().m_role.m_gameId);
			if (DWGameManager.getInstance().m_role.m_gameId == leaderID) {//自己是队长
				if (m_team_role.m_gameID == DWGameManager.getInstance().m_role.m_gameId) {//点击的是自己
					ownLeaderMyself();
				}
				else {
					ownLeaderOther();
				}
			}
			else {
				if (m_team_role.m_gameID == DWGameManager.getInstance().m_role.m_gameId) {//点击的是自己
					otherLeaderMyself();
				}
				else {
					otherLeaderOther();
				}
			}
		}
	};

	//自己是队长 点击的ziji
	private void ownLeaderMyself()
	{
		m_menu_owmself = new DWPopMenu(m_string_owmself, m_bm_pop);
		m_menu_owmself.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_menu_owmself.setDownImage(m_bm_anxia);
		m_menu_owmself.addListener(m_own_own);
		m_si_fram.addControl(m_menu_owmself);
	}

	private DWListener m_own_own = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_menu_owmself.getIndex();
			SimpleRole sr = (SimpleRole) teamList.get(m_team_index);
			switch (index) {
				case 0://查看
					DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
					break;
				case 1://解散
					DWGameManager.getInstance().getSendMessage().sendLeaderHandle(m_team_dismissTeam, sr.m_gameID,
							sr.m_name);
					break;
				case 2://离开
					DWGameManager.getInstance().getSendMessage().sendQuitTeam();
					break;
			}
			m_si_fram.removeControl(m_menu_owmself);

		}
	};

	//自己是队长，点击的是别人
	public boolean m_own_flag = true;
	public long m_own_id = 0;

	private void ownLeaderOther()
	{
		m_menu_ownother = new DWPopMenu(m_string_ownother, m_bm_pop);
		m_menu_ownother.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_menu_ownother.setDownImage(m_bm_anxia);
		m_si_fram.addControl(m_menu_ownother);

		m_menu_ownother.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				int index = m_menu_ownother.getIndex();
				SimpleRole sr = (SimpleRole) teamList.get(m_team_index);
				switch (index) {
					case 0://查看a
						DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
						break;
					case 1://加为好友
						DWGameManager.getInstance().getSendMessage()
								.sendSocialAddForName(SOCIAL_TYPE_FRIEND, sr.m_name);
						break;
					case 2://踢出队伍
						DWGameManager.getInstance().getSendMessage().sendLeaderHandle(m_team_outPlayer, sr.m_gameID,
								sr.m_name);
						break;
					case 3://转让队长
						DWGameManager.getInstance().getSendMessage().sendLeaderHandle(m_team_changeLeader, sr.m_gameID,
								sr.m_name);
						break;
					case 4://解散队伍
						DWGameManager.getInstance().getSendMessage().sendLeaderHandle(m_team_dismissTeam, sr.m_gameID,
								sr.m_name);
						break;
					case 5://传音入密
						m_own_flag = false;
						m_own_id = sr.m_gameID;
						UIWindows.getInstance().m_checked.ChatPrivate(sr.m_gameID, sr.m_name);
						break;
					case 6://交易
						break;
					case 7://加入黑名单
						DWGameManager.getInstance().getSendMessage().sendSocialAddForName(SOCIAL_TYPE_BLACKLIST,
								sr.m_name);
						break;
				}
				m_si_fram.removeControl(m_menu_ownother);
			}
		});
	}

	//别人是队长，点击自己
	private void otherLeaderMyself()
	{
		m_menu_otherown = new DWPopMenu(m_string_otherown, m_bm_pop);
		m_menu_otherown.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_menu_otherown.setDownImage(m_bm_anxia);
		m_si_fram.addControl(m_menu_otherown);
		m_menu_otherown.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				int index = m_menu_otherown.getIndex();
				SimpleRole sr = (SimpleRole) teamList.get(m_team_index);
				switch (index) {
					case 0://查看
						DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
						break;
					case 1://退出队伍
						DWGameManager.getInstance().getSendMessage().sendQuitTeam();
						break;
				}
				m_si_fram.removeControl(m_menu_otherown);
			}
		});
	}

	//别人是队长，点击别人
	public boolean m_other_flag = true;
	public long m_other_id = 0;

	private void otherLeaderOther()
	{
		m_menu_other = new DWPopMenu(m_string_other, m_bm_pop);
		m_menu_other.setNearAnchor(m_si_fram, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_menu_other.setDownImage(m_bm_anxia);
		m_si_fram.addControl(m_menu_other);
		m_menu_other.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				int index = m_menu_other.getIndex();
				SimpleRole sr = (SimpleRole) teamList.get(m_team_index);
				switch (index) {
					case 0://查看
						DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(sr.m_gameID);
						break;
					case 1://加为好友
						DWGameManager.getInstance().getSendMessage()
								.sendSocialAddForName(SOCIAL_TYPE_FRIEND, sr.m_name);
						break;
					case 2://传音入密
						m_other_flag = false;
						m_other_id = sr.m_gameID;
						UIWindows.getInstance().m_checked.ChatPrivate(sr.m_gameID, sr.m_name);
						break;
					case 3://交易
						UIWindows.getInstance().m_exchang.setActor(sr.m_gameID, sr.m_name);
						UIWindows.getInstance().m_exchang.open((byte) 0);
						break;
					case 4://加入黑名单
						DWGameManager.getInstance().getSendMessage().sendSocialAddForName(SOCIAL_TYPE_BLACKLIST,
								sr.m_name);
						break;
				}
				m_si_fram.removeControl(m_menu_other);
			}
		});
	}

	//刷新附近队伍
	private void refreshNearTeam()
	{
		if (m_si_listBox[4] != null) {
			m_si_listBox[4].removeAllSubItem();
		}
		if (nearTeamList != null && nearTeamList.size() > 0) {
			DWListSubItem[] m_item_listItem = new DWListSubItem[nearTeamList.size()];
			DWTextbox[] m_text_name = new DWTextbox[nearTeamList.size()];
			DWTextbox[] m_text_number = new DWTextbox[nearTeamList.size()];
			for (int i = 0; i < nearTeamList.size(); i++) {
				SimpleRole sr = (SimpleRole) nearTeamList.get(i);
				m_item_listItem[i] = new DWListSubItem();
				m_text_name[i] = new DWTextbox(sr.m_name, 130);
				m_text_name[i].setFont(DWFont.getFont(20));
				m_text_number[i] = new DWTextbox("" + sr.m_teamMemberNum + "/4", 80);
				m_text_number[i].setFont(DWFont.getFont(20));

				m_text_name[i].setNearAnchor(m_item_listItem[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_text_number[i].setNearAnchor(m_text_name[i], Tools.LEFT_TOP, Tools.RIGHT_TOP, 0, 0);
				m_item_listItem[i].addControls(m_text_name[i]);
				m_item_listItem[i].addControls(m_text_number[i]);
				m_si_listBox[4].addSubItem(m_item_listItem[i]);
			}
		}

	}

	private DWListener m_listBox_nearTeam = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int index = m_si_listBox[4].getTouchIndex();
			SimpleRole sr = (SimpleRole) nearTeamList.get(index);
			DWGameManager.getInstance().getSendMessage().sendTeamJoin(
					sr.m_teamID);
		}
	};

	//刷新按钮
	private DWListener m_refresh_button = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
//			refreshNearTeam();
			DWGameManager.getInstance().getSendMessage().sendTeamNear();
		}
	};

	/******************************** 队伍的逻辑 ****************************************/

	/**
	 * 获取全队的信息
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamInfo(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_队伍);
		short status = dis.readShort(); // 0失败 1成功
		String hint = dis.readUTF(); // 提示信息
		if (status == 0) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, hint);
		}
		teamID = dis.readLong(); // 队伍的ＩＤ
		if (teamID == 0) { // 队伍ＩＤ为０读到此处
			teamList = null;
			refreshMyTeam();
			return;
		}
		leaderID = dis.readLong(); // 队长的ＩＤ
		Tools.debugPrintln("组队 队长的ＩＤ" + leaderID);
		Tools.debugPrintln("队伍的ＩＤ" + teamID);

		teamList = new ArrayList<SimpleRole>();
		teamList.clear();

		int Numplayer = dis.readInt(); // 队员的数量
		Tools.debugPrintln("组队 队员的数量" + Numplayer);

		for (int i = 0; i < Numplayer; i++) {
			long id = dis.readLong();
			SimpleRole teamrole = new SimpleRole();

			teamrole.m_gameID = id;
			Tools.debugPrintln("id = " + teamrole.m_gameID);
			teamrole.m_online = dis.readByte() == 0 ? true : false;// 是否在线 0在线//
			// 1不在线

			teamrole.m_name = dis.readUTF();
			teamrole.m_grade = dis.readInt();
//			teamrole.m_race = dis.readByte(); // 种族
			teamrole.m_vocation = dis.readByte();
			teamList.add(teamrole);
			Tools.debugPrintln("name = " + teamrole.m_name);
			Tools.debugPrintln("grade = " + teamrole.m_grade);
//			Tools.debugPrintln("m_race = " + teamrole.m_race);
		}
		refreshMyTeam();
	}

	/**
	 * 接受组队请求确认
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamIsAgree(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("组队邀请");
		final byte status = dis.readByte(); // 0：申请加入队伍1：邀请加入队伍
		String name = dis.readUTF();
		final long targetID = dis.readLong();
		Tools.debugPrintln("目标ID" + targetID);

		if (status == 0) {
			final DWMessageBox mb = new DWMessageBox("入队申请", name + "请求加入您的队伍");
			mb.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
						Tools.debugPrintln("同意");
						UIHook.closeHook();
						DWControlsManager.getInstance().removeControl(mb);
						DWGameManager.getInstance().getSendMessage().sendisAgree(status, targetID, (byte) 1);
						//	UITeam.state = 1;
					}
					else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
						Tools.debugPrintln("不同意");
						UIHook.closeHook();
						DWControlsManager.getInstance().removeControl(mb);
						DWGameManager.getInstance().getSendMessage().sendisAgree(status, targetID, (byte) 0);
					}
				}
			});
			DWControlsManager.getInstance().addControl(mb);
		}
		else if (status == 1) {
			final DWMessageBox mb = new DWMessageBox("邀请组队", name + "向您发出了组队邀请");
			mb.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
						Tools.debugPrintln("同意");
						DWControlsManager.getInstance().removeControl(mb);
						DWGameManager.getInstance().getSendMessage().sendisAgree(status, targetID, (byte) 1);
//						UITeam.state = 1;
					}
					else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
						Tools.debugPrintln("不同意");
						DWControlsManager.getInstance().removeControl(mb);
						DWGameManager.getInstance().getSendMessage().sendisAgree(status, targetID, (byte) 0);
					}
				}
			});
			DWControlsManager.getInstance().addControl(mb);
		}
		refreshMyTeam();
	}

	/**
	 * 组队是否成功
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamIsSucceed(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("组队>>>>>>>>>>>>>");

		short state = dis.readShort();
		Tools.debugPrintln("状态码 : " + state);
		switch (state) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您不是该队队长，没有邀请玩家入队权限");
				break;
			case 1:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"组队成功!");
				break;
			case 2:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您的队伍已满员");
				break;
			case 3:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对方已在您的队伍中");
				break;
			case 4:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对方正在其他队伍中");
				break;
			case 5:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您在对方的黑名单中");
				break;
			case 6:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您不能邀请自己哦，亲!");
				break;
			case 7:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对方正在其他队伍中");
				break;
			case 8:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"无法创建队伍");
				break;
			case 9:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对方拒绝了您的组队邀请");
				break;
			case 10:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"传送目标玩家失败");
				break;
			case 11:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"无法获得队伍信息 ");
				break;
			case 12:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对方在您的黑名单中");
				break;
			case 13:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对方与您不在同一阵营");
				break;
		}
		refreshMyTeam();
	}

	/**
	 * 退出队伍是否成功
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamRequst(DataInputStream dis) throws IOException
	{
		short status = dis.readShort(); // 是否成功
		switch (status) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您当前不在任何队伍中");
				break;
			case 1:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您已经离开了当前队伍");
				break;
			case 2:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"无法获取队伍信息");
				break;
			case 3:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您不在当前队伍中");
				break;
		}
		Tools.debugPrintln("退出队伍>>>>>>>>>>>>>>");
		if (status == 1) {
			teamList = null;
			teamID = 0;
			DWGameManager.getInstance().m_role.m_roleTeam.removeAllElements();
			if (UIWindows.getMain() != null) {
				UIWindows.getMain().updateTeam();
			}
		}
		refreshMyTeam();
	}

	/**
	 * 队长操作
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamLeader(DataInputStream dis) throws IOException
	{
		short status = dis.readShort(); // 是否成功
		Tools.debugPrintln("队长 操作>>>>>>>>>>>>>>");
		switch (status) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您当前不在任何队伍中");
				break;
			case 1:
				break;
			case 2:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"无法获取队伍信息");
				break;
			case 3:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您不是该队队长，没有该操作权限。");
				break;
			case 4:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您不能对自己执行队长操作");
				break;
			case 5:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"转让对象不在线");
				break;
			case 6:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"对象不在您的队伍中");
				break;
		}
		byte type = dis.readByte();// 队长操作类型0:转让队长1.踢出队员2。解散
		long id = dis.readLong(); // 目标ID
		switch (type) {
			case 0:
				if (status == 1) {
					leaderID = -1;
				}

				break;
			case 1:
				if (status == 1) {
					int size = teamList.size();
					for (int i = 0; i < size; i++) {
						SimpleRole role = (SimpleRole) teamList.get(i);
						if (id == role.m_gameID) {
							teamList.remove(i);
							break;
						}
					}
				}
				break;
			case 2:
				if (status == 1) {
					teamList = null;
					teamID = 0;
					leaderID = -1;
				}
				break;
			default:
				break;
		}
		refreshMyTeam();
	}

	/**
	 * 附近队伍
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamNearby(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_队伍);
		int teamNum = dis.readInt(); // 附近队伍数量
		if (teamNum == 0 || teamNum < 0) {
			if (nearTeamList != null) {
				nearTeamList.clear();
			}
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "附近暂时没有队伍");
			refreshNearTeam();
			return;
		}
		Tools.debugPrintln("附近队伍》》》");
		nearTeamList = new ArrayList<SimpleRole>();
		for (int i = 0; i < teamNum; i++) {
			SimpleRole nearbyLeader = new SimpleRole();
			nearbyLeader.m_teamID = dis.readLong(); // 队伍ID
			nearbyLeader.m_teamMemberNum = dis.readInt();// 队伍人数
			nearbyLeader.m_name = dis.readUTF();// 队长名字
			nearbyLeader.m_location = dis.readUTF();// 队长所在的场景
			nearbyLeader.m_grade = dis.readInt();
			nearTeamList.add(nearbyLeader);
		}
		refreshNearTeam();
	}

	/**
	 * 申请入队是否成功
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamApplyJoin(DataInputStream dis) throws IOException
	{
		short stats = dis.readShort(); // 状态0 失败1成功
		switch (stats) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"无法获取对方队伍信息");
				break;
			case 1:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"申请加入队伍成功");
				break;
			case 2:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"目标队伍已满员");
				break;
			case 3:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您当前已在队伍中，不能同时加入两个队伍");
				break;
			case 4:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"您在该队队长的黑名单中");
				break;
			case 5:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"目标队伍队长不在线");
				break;
			case 6:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
						"目标队伍队长拒绝了您的加入队伍请求");
				break;
		}
		refreshMyTeam();
	}

	/**
	 * xujianping 自动组队
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTeamAutoCreate(DataInputStream dis)
			throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_队伍);
		short state = dis.readShort(); // 状态 ：0失败1成功
		String msg = dis.readUTF(); // 提示信息
		Tools.debugPrintln("Team Auto Create-->state" + state);
		Tools.debugPrintln("Team Auto Create-->提示信息" + msg);
		DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, msg);
		refreshMyTeam();
	}

	public static final byte m_team_changeLeader = 0; // 转让队长
	public static final byte m_team_outPlayer = 1; // 踢出队员
	public static final byte m_team_dismissTeam = 2;// 解散队伍
	private long teamID = 0;
	private long leaderID = 0;
	static ArrayList<SimpleRole> teamList; //队伍列表
	private ArrayList<SimpleRole> nearTeamList; //附近队伍列表

	/**
	 * 得到 DWTabControl
	 * @return
	 */
	public DWTabControl getTabCt()
	{
		if (DWControlsManager.getInstance().contains(m_si_fram) == false) {
			return null;
		}
		else
			return m_si_tc;
	}

	/**
	 * "0好友", "1婚姻", "2仇敌", "3黑名单","4我的队伍", "5附近队伍", "6师徒"
	 * @param page
	 * @return
	 */
	public DWTabPage getOneTabPage(int page)
	{
		if (page < 0 || page > 7) {
			return null;
		}
		if (DWControlsManager.getInstance().contains(m_si_fram) == false) {
			return null;
		}
		else {
			if (m_si_tabPage == null) {
				return null;
			}
			else
				return m_si_tabPage[page];
		}

	}

	/**
	 * 得到关闭按钮
	 * @return
	 */
	public DWImageBox getClose()
	{
		if (DWControlsManager.getInstance().contains(m_si_fram) == false) {
			return null;
		}
		else
			return m_si_ib[m_si_close];
	}

	/**
	 * 返回推荐好友按钮
	 * @return
	 */
	public DWButton button_open_haoyou()
	{
		if (DWControlsManager.getInstance().contains(m_si_tabPage[0]) == false) {
			return null;
		}
		else
			return m_haoyou_tuijian;
	}
	
	/**
	 * 返回推荐师傅按钮
	 * @return
	 */
	public DWButton button_open_shifu()
	{
		if (DWControlsManager.getInstance().contains(m_si_tabPage[5]) == false) {
			return null;
		}
		else
			return m_tuijian_Button;
	}
}
